0% found this document useful (0 votes)
47 views4 pages

CupCarbon Tutorials

Uploaded by

AD PLAYZ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views4 pages

CupCarbon Tutorials

Uploaded by

AD PLAYZ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

10/25/23, 12:30 PM CupCarbon Tutorials

Start with CupCarbon 6


Tutorials
Step 1

Download CupCarbon
Visit the following website and donwload CupCarbon:
www.cupcarbon.com
You unzip the file cupcarbon.zip
You will get the following files:

You need just to execute the jar file cupcarbon.jar


If CupCarbon starts, then you are lucky, you can continue to use it normally
Otherwise, it means you have a recent version of Java
CupCarbon works only with the version 8 (1.8.xxx). Since we are using JavaFX platform, CupCarbon can run only with the Java 8 version.
Therefore, you may install the version 8 (JRE 1.8) of java in your system
To do that, visit the following web page: (www.java.com). Verify that you are installing the version 8.
Once done, you can double click again on the file cupcarbon.jar and start using CupCarbon normally.

If CupCarbon does not start then you may check the version of java installed in your system, you can use the following command:

java -version

Verify that the version is 1.8.xxx


In case where the version is not 8 then depending on your system you should either change the current default version to 8 or to install the jre directly from the
website of oracle:

https://www.oracle.com/java/technologies/downloads/#java8-mac
Go to the section: Java SE Development Kit 8u391
Choose your platform and download the installer.
Once Java installed run CupCarbon using the java command:

java -jar cupcarbon.jar

If it does not work, then run CupCarbon using the complete path of Java. For example, for mac OS, go to the directory where the cupcarbon.jar is situated and write
the following command:

/Library/Java/JavaVirtualMachines/jdk1.8xx.jdk/Contents/Home/bin/java -jar cupcarbon.jar

jdk1.8xx can be any version starting with 1.8.

cupcarbon.com/CupCarbon-Tutorials.html 1/4
10/25/23, 12:30 PM CupCarbon Tutorials

Step 2

Install Python
You can install any version of Python you want.
To verify if Python is installed you can use the following command:

python -V

Python is completely independent from CupCarbon, once installed, you have to use the system command used to execute Python programs.
Basically this command can by python or python3

python

It can be a complete path where the command is situated in your system. You can add this commande (or path) in the Executor Path Configuration window as shown
by the following figures:

cupcarbon.com/CupCarbon-Tutorials.html 2/4
10/25/23, 12:30 PM CupCarbon Tutorials

Now you can use CupCarbon, enjoy!

Step 3

Visualisation
To interace with CupCarbon from your Python codes, you can send commands to CupCarbon and you can get commands from CupCarbon as well.
To send commands from your code Python to CupCarbon, use the command print of Python normally. The message of the print will be considered as a CupCarbon
command. You need to flush each command to send it directly, otherwise, all the commands will be sent once at the end of the program. In this case you have to use
the command:
sys.stdout.flush() after each print command

To use this command you need to import the library sys, as follows:
import sys

In a nutshell:
Any Python program communicating with CupCarbon has to import the library sys, to send the CupCarbon comands using the command print and to flush the
message (send it to CupCarbon) using the command flush:

print("CupCarbon command", flush=True)

The different commands that you can send to CupCarbon are given as follows:

1. print
To print any message on the executing device, use the command print as follows:

print("print Hellow World!", flush=True)

2. mark/unmark
To mark or unmark the executing device, use the commande mark or unmark as follows:

print("mark", flush=True)
print("unmark", flush=True)

3. move
To move the executing device to a given GPS location, use the move command as follows:

print("move 50.002 21.344", flush=True)

4. To get any information about the executing device sugh as, its id, its name and its location, use the following commands:

print("getid", flush=True)
id = input()

print("getname", flush=True)
name = input()

print("getxy", flush=True)
location = input()

print("getx", flush=True)
x = input()

print("gety", flush=True)
y = input()

Step 4

Install MQTT for Python


To create IoT Projects using the MQTT protocol, just install MQTT for Python.
You can use the following command:
pip install paho-mqtt
or
pip3 install paho-mqtt

Many tutorials exists on the web. We suggest the following websites


https://pypi.org/project/paho-mqtt/
https://www.emqx.com/en/blog/how-to-use-mqtt-in-python
cupcarbon.com/CupCarbon-Tutorials.html 3/4
10/25/23, 12:30 PM CupCarbon Tutorials

It is possible to use MQTT in different real devices (Android device, iOS, ESP32, Raspberry, ...) to communicate with CupCarbon devices.

You can install Mosquitto to use MQTT from the terminal of your system.
https://mosquitto.org/download/

Two samples (Pbulisher and Subscriber) are given in CupCarbon that can be used directly. Don't forget to set the value of the broker and the topics if you are using
these codes.

TUTORIALS
Tutorial 1: Hello World!
source code

Tutorial 2: Alternate Hello & World!


source code

Tutorial 3: Get Device Infos


source code

Tutorial 4: Blink
source code

Tutorial 5: Move
source code

Tutorial 6: MQTT (example 1)


source code

Tutorial 7: MQTT Python and Mosquitto (1)


source code

Tutorial 8: MQTT Python and Mosquitto (2)


source code

cupcarbon.com/CupCarbon-Tutorials.html 4/4

You might also like