Thank you!
I use the Arduino Explore IoT kit: https://www.arduino.cc/education/explore-iot-kit
The MKR IoT Carrier is mounted on top of the The Arduino MKR WiFi 1010 board. The Arduino 1010 stays connected with the computer via USB.
The code below will work the first time I upload it. It will render nice printouts in the Arduino Editor/Monitor.
/*
Explore IoT - Activity 01
Read values from a temperature and humidity sensor
and print it in Serial Monitor and on a colored display.
This example uses the IoT carrier and the MKR WiFi 1010.
Based on code by
(c) 2019 D. Cuartielles for Arduino
Written by:
(c) 2020 K. Söderby for Arduino
This code is Free Software licensed under GPLv3
*/
#include <Arduino_MKRIoTCarrier.h>
MKRIoTCarrier carrier;
float temperature = 0;
float humidity = 0;
void setup() {
Serial.begin(9600);
//Wait to open the Serial monitor to start the program and see details on errors
//Set if it has the Enclosure mounted
CARRIER_CASE = false;
//Initialize the IoTSK carrier and output any errors in the serial monitor
carrier.begin();
}
void loop() {
// read the sensor values
temperature = carrier.Env.readTemperature();
humidity = carrier.Env.readHumidity();
//Update touch buttons
carrier.Buttons.update();
// print each of the sensor values
Serial.print("Temperatur = ");
Serial.print(temperature);
Serial.println(" °C");
Serial.print("Fuktighet = ");
Serial.print(humidity);
Serial.println(" %");
//function to print out values
if (carrier.Buttons.onTouchDown(TOUCH0)) {
printTemperature();
}
if (carrier.Buttons.onTouchDown(TOUCH1)) {
printHumidity();
}
}
void printTemperature() {
//configuring display, setting background color, text size and text color
carrier.display.fillScreen(ST77XX_RED); //red background
carrier.display.setTextColor(ST77XX_WHITE); //white text
carrier.display.setTextSize(6); //large sized text
carrier.display.setCursor(30, 50); //sets position for printing (x and y)
carrier.display.print("Temp: ");
carrier.display.setTextSize(4); //decreasing text size
carrier.display.setCursor(40, 120); //sets new position for printing (x and y)
carrier.display.print(temperature);
carrier.display.print(" C");
}
void printHumidity() {
//configuring display, setting background color, text size and text color
carrier.display.fillScreen(ST77XX_BLUE); //red background
carrier.display.setTextColor(ST77XX_WHITE); //white text
carrier.display.setTextSize(2); //medium sized text
carrier.display.setCursor(20, 110); //sets position for printing (x and y)
carrier.display.print("Humi: ");
carrier.display.print(humidity);
carrier.display.println(" %");
}
Any subsequent change of the code, such as changing the string "Temp" to "Temperature" will result in the code not being uploaded and there will be no printouts in the monitor.
The output generated from the working vs the non working case looks very similar (I compared them). The only difference is to be found in folder names and "done in 0.756 s" vs "done in 0.751 s" or checksumBuffer f0b1 vs 7d77.
This output is from the non working case:
/usr/local/bin/arduino-cli compile --fqbn arduino:samd:mkrwifi1010 --build-cache-path /tmp --output-dir /tmp/523206074/build --build-path /tmp/arduino-build-2B0BFA1858B00E3237A165BB0F2F7B2D /tmp/523206074/Activity01
Sketch uses 96836 bytes (36%) of program storage space. Maximum is 262144 bytes.
Global variables use 6924 bytes (21%) of dynamic memory, leaving 25844 bytes for local variables. Maximum is 32768 bytes.
Upload started
Programming with: Serial
Restarting in bootloader mode
Flashing with command:C:/Users/perab/.arduino-create/arduino/bossac/1.7.0-arduino3/bossac.exe -i -d --port=COM4 -U true -i -e -w -v C:/Users/perab/AppData/Local/Temp/arduino-create-agent423416680/Activity01.bin -R
Set binary mode
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
version()=v2.0 [Arduino:XYZ] Mar 19 2018 09:45:14
chipId=0x10010005
Connected at 921600 baud
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
Atmel SMART device 0x10010005 found
write(addr=0x20004000,size=0x34)
writeWord(addr=0x20004030,value=0x10)
writeWord(addr=0x20004020,value=0x20008000)
Device : ATSAMD21G18A
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
Chip ID : 10010005
version()=v2.0 [Arduino:XYZ] Mar 19 2018 09:45:14
Version : v2.0 [Arduino:XYZ] Mar 19 2018 09:45:14
Address : 8192
Pages : 3968
Page Size : 64 bytes
Total Size : 248KB
Planes : 1
Lock Regions : 16
Locked : readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
none
readWord(addr=0x41004018)=0
Security : false
Boot Flash : true
readWord(addr=0x40000834)=0x7000a
BOD : true
readWord(addr=0x40000834)=0x7000a
BOR : true
Arduino : FAST_CHIP_ERASE
Arduino : FAST_MULTI_PAGE_WRITE
Arduino : CAN_CHECKSUM_MEMORY_BUFFER
Erase flash
chipErase(addr=0x2000)
done in 0.811 seconds
Write 96844 bytes to flash (1514 pages)
write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x2000, size=0x1000)
[= ] 4% (64/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x3000, size=0x1000)
[== ] 8% (128/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x4000, size=0x1000)
[=== ] 12% (192/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x5000, size=0x1000)
[===== ] 16% (256/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x6000, size=0x1000)
[====== ] 21% (320/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x7000, size=0x1000)
[======= ] 25% (384/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x8000, size=0x1000)
[======== ] 29% (448/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x9000, size=0x1000)
[========== ] 33% (512/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0xa000, size=0x1000)
[=========== ] 38% (576/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0xb000, size=0x1000)
[============ ] 42% (640/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0xc000, size=0x1000)
[============= ] 46% (704/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0xd000, size=0x1000)
[=============== ] 50% (768/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0xe000, size=0x1000)
[================ ] 54% (832/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0xf000, size=0x1000)
[================= ] 59% (896/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x10000, size=0x1000)
[=================== ] 63% (960/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x11000, size=0x1000)
[==================== ] 67% (1024/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x12000, size=0x1000)
[===================== ] 71% (1088/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x13000, size=0x1000)
[====================== ] 76% (1152/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x14000, size=0x1000)
[======================== ] 80% (1216/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x15000, size=0x1000)
[========================= ] 84% (1280/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x16000, size=0x1000)
[========================== ] 88% (1344/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x17000, size=0x1000)
[=========================== ] 92% (1408/1514 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x18000, size=0x1000)
[============================= ] 97% (1472/1514 pages)write(addr=0x20005000,size=0xa80)
writeBuffer(scr_addr=0x20005000, dst_addr=0x19000, size=0xa80)
[==============================] 100% (1514/1514 pages)
done in 0.762 seconds
Verify 96844 bytes of flash with checksum.
checksumBuffer(start_addr=0x2000, size=0x1000) = f0b1
checksumBuffer(start_addr=0x3000, size=0x1000) = e0ea
checksumBuffer(start_addr=0x4000, size=0x1000) = e530
checksumBuffer(start_addr=0x5000, size=0x1000) = 1f3a
checksumBuffer(start_addr=0x6000, size=0x1000) = abd3
checksumBuffer(start_addr=0x7000, size=0x1000) = 801e
checksumBuffer(start_addr=0x8000, size=0x1000) = 8ede
checksumBuffer(start_addr=0x9000, size=0x1000) = ee8a
checksumBuffer(start_addr=0xa000, size=0x1000) = 1a9a
checksumBuffer(start_addr=0xb000, size=0x1000) = c050
checksumBuffer(start_addr=0xc000, size=0x1000) = 7c93
checksumBuffer(start_addr=0xd000, size=0x1000) = 8095
checksumBuffer(start_addr=0xe000, size=0x1000) = d0ee
checksumBuffer(start_addr=0xf000, size=0x1000) = 4b2a
checksumBuffer(start_addr=0x10000, size=0x1000) = c6a9
checksumBuffer(start_addr=0x11000, size=0x1000) = c19b
checksumBuffer(start_addr=0x12000, size=0x1000) = ae5c
checksumBuffer(start_addr=0x13000, size=0x1000) = c431
checksumBuffer(start_addr=0x14000, size=0x1000) = 74df
checksumBuffer(start_addr=0x15000, size=0x1000) = b9ac
checksumBuffer(start_addr=0x16000, size=0x1000) = ea76
checksumBuffer(start_addr=0x17000, size=0x1000) = d1f8
checksumBuffer(start_addr=0x18000, size=0x1000) = 1475
checksumBuffer(start_addr=0x19000, size=0xa4c) = cbf
Verify successful
done in 0.087 seconds
CPU reset.
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
writeWord(addr=0xe000ed0c,value=0x5fa0004)
If I take a look in the Debug Console this can be found:
{
"Version": "1.3.0"
}
{
"Commands": [
"list",
"open <portName> <baud> [bufferAlgorithm: ({default}, timed, timedraw)]",
"(send, sendnobuf, sendraw) <portName> <cmd>",
"close <portName>",
"restart",
"exit",
"killupload",
"downloadtool <tool> <toolVersion: {latest}> <pack: {arduino}> <behaviour: {keep}>",
"log",
"memorystats",
"gc",
"hostname",
"version"
]
}
{
"Hostname": "Teknikdator"
}
{
"OS": "windows"
}
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
Network Ports:
[]
list
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
Network Ports:
[]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
Network Ports:
[]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
Network Ports:
[]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
Network Ports:
[]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]
list
Network Ports:
[]
Serial Ports:
[
{
"Name": "COM3",
"SerialNumber": "9CDF31CE5154465341202020FF183528",
"IsOpen": true,
"VendorID": "0x2341",
"ProductID": "0x8054"
}
]