Hello. I got Basic and Core2. I want to make a door sensor by connecting ”M5stack”, ”COM.sigfox” and a ”magnet sensor”. Does anyone know of a helpful sketch or program?
takero
@takero
Posts made by takero
-
I want to make a door sensor.
-
RE: About sensors and GPIO
@zontex Thank you.
DHT, DS18B20 and Soil Moisture Sensor are not M5 products. Use Arduino.
Thank you. -
About sensors and GPIO
Hello.
I want to connect the sensors DHT22 and DS18B20 and the capacitive soil moisture sensor to Core 2 for operation.
Below is the sketch. However, when I wrote the sketch with the pin stuck, fatal error occurred.And after that, I couldn't write.Core 2 has been lucky enough to come back, but it's scary.Therefore, I would like to know the GPIO that should point to the sensor. Please let me know.
Thank you.//#include <M5Stack.h> #include <M5Core2.h> #include "DHT.h" //#define DHTPIN 13 // Basic.DHT22. #define DHTPIN 27 // Core2.DHT22 .19.27 #define DHTTYPE DHT22 DHT dht(DHTPIN, DHTTYPE); #include <OneWire.h> //DS18B20 #include <DallasTemperature.h> //DS18B20 //#define ONE_WIRE_BUS 0 // Basic.DS18B20. #define ONE_WIRE_BUS 26 // Core2.DS18B20.25.26.27 OneWire oneWire(ONE_WIRE_BUS); // OneWire DallasTemperature sensors(&oneWire);// Dallas Temperature sensor #define PinSoilMoist 35 //CapSoilMoistSensor const int dry = 3700; const int wet = 1400; int inttemp , inthumid ; int intsoilmoist , soilval , intsoiltemp; float temperature, humidity, soilMoist, soilTemp; void getData() { delay(2000); dht.begin(); float temperature = dht.readTemperature(); float humidity = dht.readHumidity(); if (isnan(temperature) || isnan(humidity) ) { Serial.println(F("Failed to read from DHT sensor!")); return; } inttemp = int ( temperature ); inthumid = int ( humidity ); Serial.print( inttemp ); Serial.println(" *C, "); Serial.print( inthumid ); Serial.println(" RH% "); soilMoist = analogRead(PinSoilMoist); soilval = map(soilMoist, dry, wet, 0, 100); if(soilval >= 99) { intsoilmoist = 99; } else if(soilval <=20) { intsoilmoist = 20; } else if(soilval >21 && intsoilmoist < 99) { intsoilmoist = soilval ; } // Serial.print( soilMoist ); Serial.println(" Pin "); Serial.print( intsoilmoist ); Serial.println(" soil% "); delay(250); sensors.requestTemperatures(); float soilTemp = sensors.getTempCByIndex(0); intsoiltemp = int ( soilTemp ); Serial.print( intsoiltemp ); Serial.println(" soil*C, "); } void sendSigfox() { String msg = String (inttemp, HEX) + String (inthumid, HEX) + String (intsoilmoist, HEX) + String (intsoiltemp, HEX); Serial2.println("AT$SF=" + msg); Serial.println("AT$SF=" + msg); } void setup() { M5.begin(true, false, true); // M5.Speaker.write(0); // M5.Axp.SetSpkEnable(0); // Serial2.begin(9600, SERIAL_8N1, 16, 17); Serial2.begin(9600, SERIAL_8N1, 13, 14); // Serial.begin(9600); } void loop() { getData(); sendSigfox(); // M5.Power.deepSleep(SLEEP_SEC(60*15)); M5.Axp.DeepSleep(SLEEP_SEC(60*0.5)); }
-
RE: I want to communicate data with M5stack Core2 and COM.Sigfox.
@felmue
While I was writing to Core 2, I pressed the power button for a long time and the writing was successful.Thank you.
-
RE: I want to communicate data with M5stack Core2 and COM.Sigfox.
Thank you @felmue .I have tried your suggestion.
Have you tried a different USB cable? :Yes I did.
Have you tried a different USB port? :Yes I did.
Have you tried closing and reopening your software? :Yes I did.
Have you tried to reboot your computer? :Yes I did.However, I got an error. Isn't my Core 2 broken ?
I tried another sketch and the result was the same.
At that time, I connected the actual sensor.
DHT22 to GPIO72.
DS18B20 to GPIO26.
Analog sensor to GPIO36.
Is that not good?
Thank you. -
RE: I want to communicate data with M5stack Core2 and COM.Sigfox.
@felmue Thank you.
I tried your sample. I succeeded in compiling.
But I can't write to core2 since yesterday.Displayed "A fatal error occurred: Failed to connect to ESP32: Timed out Waiting for packet header"
Both of the Core2 I have are like that. Did my Core 2 break?
I just wrote a sketch.Thank you.
-
RE: I want to communicate data with M5stack Core2 and COM.Sigfox.
@felmue
Thank you for suggestion Felix. And Sorry for my late reply.
I triedSerial2.println("AT$SF=" + msg );
.
orSerial2.println("AT$SF= + msg ");
.and
Serial2.write("AT$SF= + msg ");
.
orSerial2.write("AT$SF=" + msg );
.But I couldn't communicate.
If you have new tips, I would love to try.Thank you.
-
I want to communicate data with M5stack Core2 and COM.Sigfox.
Hello. I bought M5stack Core2 and COM.Sigfox. I want to use this for data communication.
I was able to register the module in the sigfox backend. But I can't communicate or call back.
When I use M5stack Basic and COM.Sigfox,I can do data communication and callbacks.
Is there something wrong with my sketch?#include <M5Core2.h> void setup() { M5.begin(true, false, true); Serial2.begin(9600, SERIAL_8N1, 13, 14); Serial.begin(9600); } void loop() { int val = 11223344; String msg = String(val, HEX); Serial.print( msg); Serial.println(" msg "); Serial2.print("AT$SF=" + msg); Serial.print("AT$SF=" + msg); Serial.println(" AT$SF= msg "); delay(15*1000); }
-
How to use COM.X Sigfox with M5Stack and M5Core2
Hello.
I purchased M5stack Basic and Core2.
I want to connect COM.X Sigfox to this and communicate with sigfox.
So I installed the Arduino IDE, USB serial driver, board definitions and libraries on my PC. And
I tried to write a sample sketch to get ID / PAC information to M5stack.M5stack Basic was successful.
The following error message was displayed on M5stack Cors2.
File "esptool.py", line 3682, in <module>
Serial port COM3
File "esptool.py", line 3675, in _main
File "esptool.py", line 3329, in main
File "esptool.py", line 263, in init
File "site-packages \ serial \ __ init__.py", line 88, in serial_for_url
File "site-packages \ serial \ serialwin32.py", line 62, in open
serial.serialutil.SerialException: could not open port'COM3': WindowsError (2,'\ x8ew \ x92 \ xe8 \ x82 \ xb3 \ x82 \ xea \ x82 \ xbd \ x83t \ x83 @ \ x83C \ x83 \ x8b \ x82 \ xaa \ x8c \ xa9 \ x82 \ xc2 \ x82 \ xa9 \ x82 \ xe8 \ x82 \ xdc \ x82 \ xb9 \ x82 \ xf1 \ x81B')
Failed to execute script esptool
When Basic is connected to the PC, it is connected to com3 in Device Manager, but when Core2 is connected, it is com7. Something is wrong.
What should I do? please tell me. Thank you.