Shadi
11/24/2022, 1:35 PMfloitsch
11/24/2022, 2:47 PMfloitsch
11/24/2022, 2:47 PMfloitsch
11/24/2022, 2:48 PMfloitsch
11/24/2022, 2:48 PMShadi
11/24/2022, 3:00 PMfloitsch
11/24/2022, 3:00 PMfloitsch
11/24/2022, 3:00 PMfloitsch
11/24/2022, 3:01 PMShadi
11/24/2022, 3:02 PMShadi
11/24/2022, 3:03 PMfloitsch
11/24/2022, 3:03 PMfloitsch
11/24/2022, 3:03 PMShadi
11/24/2022, 3:03 PMfloitsch
11/24/2022, 3:04 PMShadi
11/24/2022, 3:04 PMShadi
11/24/2022, 3:04 PMfloitsch
11/24/2022, 3:04 PMfloitsch
11/24/2022, 3:04 PMShadi
11/24/2022, 3:05 PMfloitsch
11/24/2022, 3:05 PMfloitsch
11/24/2022, 3:05 PMclean_session
flag.floitsch
11/24/2022, 3:05 PMfloitsch
11/24/2022, 3:06 PMShadi
11/24/2022, 3:07 PMfloitsch
11/24/2022, 3:07 PMclean_session
would be a flag to the SessionOption
.floitsch
11/24/2022, 3:08 PMfloitsch
11/24/2022, 3:08 PMfloitsch
11/24/2022, 3:08 PMfloitsch
11/24/2022, 3:08 PMShadi
11/24/2022, 3:09 PMfloitsch
11/24/2022, 3:09 PMfloitsch
11/24/2022, 3:09 PMfloitsch
11/24/2022, 3:09 PMfloitsch
11/24/2022, 3:10 PMfloitsch
11/24/2022, 3:10 PMShadi
11/24/2022, 3:12 PMfloitsch
11/24/2022, 3:12 PMfloitsch
11/24/2022, 3:12 PMfloitsch
11/24/2022, 3:12 PMfloitsch
11/24/2022, 3:13 PMimport .sensor1 as sensor1
import .sensor2 as sensor2
import .sensor3 as sensor3
import mqtt
main:
// Create mqtt client.
client := ..
sensor1.main_with_client client
sensor2.main_with_client client
sensor3.main_with_client client
Shadi
11/24/2022, 3:13 PMfloitsch
11/24/2022, 3:13 PMfloitsch
11/24/2022, 3:14 PMtask
(which I forgot).Shadi
11/24/2022, 3:14 PMfloitsch
11/24/2022, 3:14 PMShadi
11/24/2022, 3:14 PMfloitsch
11/24/2022, 3:14 PMShadi
11/24/2022, 3:15 PMfloitsch
11/24/2022, 3:15 PMfloitsch
11/24/2022, 3:16 PMSimpleService
), which takes data, and then pushes it to the mqtt broker.
The test just does a print
in the log
function. You would do a client.publish
instead.floitsch
11/24/2022, 3:17 PMspawn
to launch a second app. You wouldn't need to do that, as your different containers would already run.Shadi
11/24/2022, 3:19 PMShadi
11/24/2022, 3:57 PMShadi
11/24/2022, 3:58 PMfloitsch
11/24/2022, 3:59 PMShadi
11/24/2022, 4:00 PMfloitsch
11/24/2022, 4:00 PMShadi
11/24/2022, 4:00 PMfloitsch
11/24/2022, 4:00 PMfloitsch
11/24/2022, 4:01 PMfloitsch
11/24/2022, 4:02 PMShadi
11/24/2022, 4:02 PMfloitsch
11/24/2022, 4:09 PMimport dht11
import gpio
import mqtt
import net
import certificate_roots
PIN_NUMBER_1 ::= 25
ADAFRUIT_IO_FEEDNAME ::= "toit_2"
PIN_NUMBER_2 ::= 32
ADAFRUIT_IO_FEEDNAME_2 ::= "toit_1"
ADAFRUIT_IO_USERNAME ::= "your_username"
ADAFRUIT_IO_KEY ::= "your_key"
HOST ::= "io.adafruit.com"
main:
network := net.open
transport := mqtt.TcpTransport.tls network
--host=HOST
--root_certificates=[ certificate_roots.DIGICERT_GLOBAL_ROOT_CA ]
client := mqtt.Client --transport=transport
options := mqtt.SessionOptions
--client_id = "toit-example-client" // <== feel free to use a more descriptive name.
--username = ADAFRUIT_IO_USERNAME
--password = ADAFRUIT_IO_KEY
client.start --options=options
print "Connected to the broker"
sensor1 := dht11.Dht11 (gpio.Pin PIN_NUMBER_1)
topic1 := "$ADAFRUIT_IO_USERNAME/feeds/$ADAFRUIT_IO_FEEDNAME"
sensor2 := dht11.Dht11 (gpio.Pin PIN_NUMBER_2)
topic2 := "$ADAFRUIT_IO_USERNAME/feeds/$ADAFRUIT_IO_FEEDNAME_2"
while true:
th1 := sensor1.read
print "Temperature 1: $th1.temperature"
print "Humidity 1: $th1.humidity"
client.publish topic1 "$th1.temperature".to_byte_array
th2 := sensor2.read
print "Temperature 2: $th2.temperature"
print "Humidity 2: $th2.humidity"
client.publish topic2 "$th2.temperature".to_byte_array
// Make sure to have some delay between sending messages.
// Adafruit only accepts one message every 2 seconds (and we
// are sending them in pairs).
sleep --ms=5_000
floitsch
11/24/2022, 4:10 PMfloitsch
11/24/2022, 4:11 PMfloitsch
11/24/2022, 4:11 PMShadi
11/24/2022, 4:13 PMfloitsch
11/24/2022, 4:13 PMfloitsch
11/24/2022, 4:13 PMfloitsch
11/24/2022, 4:14 PMsleep
won't really help.floitsch
11/24/2022, 4:14 PMfloitsch
11/24/2022, 4:14 PMfloitsch
11/24/2022, 4:15 PMShadi
11/24/2022, 4:15 PMfloitsch
11/24/2022, 4:15 PMShadi
11/24/2022, 4:16 PMfloitsch
11/24/2022, 4:16 PMapp1.main
refers to the import app1
.
It should have probably been import .app1 as app1
where app1.toit
would be the program app1.floitsch
11/24/2022, 4:16 PMfloitsch
11/24/2022, 4:16 PMShadi
11/24/2022, 4:17 PMfloitsch
11/24/2022, 4:17 PMShadi
11/24/2022, 4:17 PMfloitsch
11/24/2022, 4:17 PMjag flash
or jag run
?Shadi
11/24/2022, 4:17 PMfloitsch
11/24/2022, 4:17 PMfloitsch
11/24/2022, 4:18 PMjag flash
should just write a firmware onto your device.Shadi
11/24/2022, 4:20 PMfloitsch
11/24/2022, 4:21 PMjag
should download everything it needs.floitsch
11/24/2022, 4:21 PMjag setup
)Shadi
11/24/2022, 4:36 PMShadi
11/24/2022, 4:36 PMfloitsch
11/24/2022, 4:36 PMfloitsch
11/24/2022, 4:37 PMShadi
11/24/2022, 4:39 PMfloitsch
11/24/2022, 4:40 PMfloitsch
11/24/2022, 4:40 PMjag monitor
show?floitsch
11/24/2022, 4:40 PMjag monitor
and then press the reset button.Shadi
11/24/2022, 4:43 PMfloitsch
11/24/2022, 4:43 PMfloitsch
11/24/2022, 4:43 PMShadi
11/24/2022, 4:44 PMShadi
11/24/2022, 4:44 PMfloitsch
11/24/2022, 4:44 PMjag scan 10.10.155.156
floitsch
11/24/2022, 4:45 PMfloitsch
11/24/2022, 4:45 PMfloitsch
11/24/2022, 4:45 PMjag scan ...
you tell Jaguar that you know where the device is, and that it shouldn't look for these packets.floitsch
11/24/2022, 4:45 PMjag run ...
should work.Shadi
11/24/2022, 4:47 PMfloitsch
11/24/2022, 4:47 PMShadi
11/24/2022, 4:48 PMfloitsch
11/24/2022, 4:48 PMfloitsch
11/24/2022, 4:48 PMShadi
11/24/2022, 4:50 PMfloitsch
11/24/2022, 4:51 PMfloitsch
11/24/2022, 4:51 PMShadi
11/24/2022, 4:52 PMfloitsch
11/24/2022, 4:53 PMfloitsch
11/24/2022, 4:53 PMfloitsch
11/24/2022, 4:54 PMShadi
11/24/2022, 4:58 PMfloitsch
11/24/2022, 5:01 PMfloitsch
11/24/2022, 5:01 PMShadi
11/24/2022, 5:02 PMfloitsch
11/24/2022, 5:03 PMShadi
11/24/2022, 5:04 PMShadi
11/25/2022, 3:32 PMfloitsch
11/25/2022, 3:32 PMfloitsch
11/25/2022, 3:32 PMesp32
library is only for v2 (Jaguar).floitsch
11/25/2022, 3:32 PMfloitsch
11/25/2022, 3:33 PMfloitsch
11/25/2022, 3:33 PMShadi
11/25/2022, 3:34 PMfloitsch
11/25/2022, 3:35 PMfloitsch
11/25/2022, 3:35 PMfloitsch
11/25/2022, 3:35 PMfloitsch
11/25/2022, 3:35 PMShadi
11/25/2022, 3:35 PMfloitsch
11/25/2022, 3:36 PMimport esp32
.floitsch
11/25/2022, 3:37 PMtoit
for the syntax highlighting and analysis.floitsch
11/25/2022, 3:37 PMtoit
and jag
), though.floitsch
11/25/2022, 3:38 PMShadi
11/25/2022, 3:38 PMfloitsch
11/25/2022, 3:39 PMShadi
11/25/2022, 3:39 PMfloitsch
11/25/2022, 3:39 PMimport esp32
doesn't work is a different error.Shadi
11/25/2022, 3:41 PMfloitsch
11/25/2022, 3:42 PMShadi
11/25/2022, 3:44 PM