Im starting to upgrade all my sensor nodes to use mysensors library after a ling time just using nrf24network with my own star topology implementation:
I design my own board to put the pro and radio and use the tuner transfer method.
Mickey
@Mickey
Best posts made by Mickey
-
MySensors first nodes ( after a long time using only NRF24NETWORK library )
-
allow sensors to operate on voltage lower than 2.7v
Hi
I made this boards as small as I could and would like to operate them on 3v coin battery - CR2032.
I check them all and the range is excellent (more than 15 meter and behind 3 brick walls)
but they will run out of power quite soon with this battery so what is the simplest and fastest way to change the arduino fuses so it can run down to 1.8v.
If there is a need for external flash I have this one(is it good?):
-
bootloader
Hi
I see in the git repo that there are 2 bootloaders:
Bootloader
MYSBootloader
Do I need to burn one of them to use MySensors ? -
RE: Sensebender Micro
However if someone has a good proposal for how these kind of batteries are best used with the Sensebender Micro I would like to know also.
mcp1702 for example...
-
RE: arduino pro 3.3 + nrf24l01 smd onboard + On board 4K-Bit Flash memory
@Sweebee said in arduino pro 3.3 + nrf24l01 smd onboard + On board 4K-Bit Flash memory:
@Mickey Nice, can you show the inside of the box?
-
RE: bootloader
Thanks a lot...
I already create a MYSController and GW + 2 NODES but your explanation made things much clearer especially the OTA part.
Do you plan to publish MYSController source?and again I really appreciate the detailed step by step guide.
-
eeprom address for node id
Hi
I want to develop a node that need to save some data to local node eeprom. but I wouldn't want to erase the node id and other params that the mysensors library saving.
how much room is available for my node ( arduino pro mini 328 ) and from where can I write to eeprom without erasing anything? -
GatewayESP8266MQTTClient with realtime connection params
Hi
I would like to alter GatewayESP8266MQTTClient.ino a bit to be able to transfer mqtt broker connection params from an HTML5 app I developed.
I altered the core code in the file MyGatewayTransportMQTTClient.cpp to enable SMARTCONFIG:
WiFi.beginSmartConfig();
To be able to transfer the SSID and PASS dynamically from the app.All the other params(server IP, user/password for MQTT broker etc.) I would send from the app with JSON and the GATEWAY will save them to local storage (the ESP-12 have 4mb for storage).
I do not want to alter core files too much and would like to implement all of the above in the ino file as much as I can.(with the smart config option I didn't see a way other than altering the MyGatewayTransportMQTTClient file.)The MyGatewayTransportMQTTClient file looks for defined variables to function but I need to change the code to enable dynamic params.
The parameters I need to change are:
#define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out" #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in" #define MY_MQTT_CLIENT_ID "mysensors-1" #define MY_MQTT_USER "username" #define MY_MQTT_PASSWORD "password" #define MY_ESP8266_SSID "MySSID" #define MY_ESP8266_PASSWORD "MyVerySecretPassword" #define MY_ESP8266_HOSTNAME "mqtt-sensor-gateway" #define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 68 #define MY_PORT 1883
I know how to code the ino file to listen to JSON and then process the data and put it in storage but I cant seem to grasp how to change the core file as minimally as I can...
-
RE: Gateway to hands out node ID's
@hek said:
Why pass it to the sketch? You could implement the id-handout directly in core (I pointed out the area where internal messages directed to the node is processed).
To mess with core as little as I could so it can be easy upgradable in future (I already altered the MyGatewayTransportMQTTClient.cpp to support using dynamic connection parameters instead hard coded , I don't want to alter a lot of core files but if it necessary I will...)
Latest posts made by Mickey
-
RE: Esp32-cam with pan - Mysensors powered
@franz-unix it really an overkill... you can use gpio from esp to control pan and tilt no need for atmega and nrf...
-
RE: Cheap dirty way to send a raw-mysensors message?
@cimba007
Can you post the complete code of the chirp including the headers?
Did you only include these libraries:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
? -
RE: GatewayESP8266MQTTClient with realtime connection params
Is the
"bcn_timout,ap_probe_send_start
ap_probe_send over, rest wifi status to disassoc"message is a known issue? I cant seem to find anything with this string when searching this forum...
-
RE: GatewayESP8266MQTTClient with realtime connection params
So after seeing this post:
https://forum.mysensors.org/topic/5533/esp8266-gw-node-mqtt-transport-won-t-present-sketch-or-actuator-to-controllerI finally succeeded to change the GatewayESP8266MQTTClient that it can load connection parameters dynamicaly and also use smart config to send SSID and password to the ESP.(I using a android app I developped for it).
This is the source code of GatewayESP8266MQTTClient:#include <EEPROM.h> #include <SPI.h> #include <ESP8266WiFi.h> #include <ESP8266WebServer.h> #include <ArduinoJson.h> #include <FS.h> const int button = 0;//button for reset config ESP8266WebServer server (80); File configFile; boolean configExist = false; struct My_Config_t { String WLAN_STA_SSID = ""; String WLAN_STA_PASSWD = ""; String MQTT_Broker_FQDN = ""; //IPAddress MQTT_Broker_IP; uint16_t MQTT_Broker_Port = 0; } My_Config; // Enable debug prints to serial monitor #define MY_DEBUG //#define MY_DEBUG_VERBOSE //#define TRANSPORT_DEBUG // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h #define MY_BAUD_RATE 9600 // Enables and select radio type (if attached) #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_GATEWAY_MQTT_CLIENT #define MY_GATEWAY_ESP8266 // Set this nodes subscripe and publish topic prefix #define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out" #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in" // Set MQTT client id #define MY_MQTT_CLIENT_ID "mysensors-1" // Enable these if your MQTT broker requires usenrame/password //#define MY_MQTT_USER "username" //#define MY_MQTT_PASSWORD "password" // Set WIFI SSID and password #define MY_ESP8266_SSID (My_Config.WLAN_STA_SSID).c_str() #define MY_ESP8266_PASSWORD (My_Config.WLAN_STA_PASSWD).c_str() // MQTT broker ip address. //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 68 //#define MY_CONTROLLER_URL_ADDRESS "test.mosquitto.org" #define MY_CONTROLLER_URL_ADDRESS ((My_Config.MQTT_Broker_FQDN).c_str()) // The MQTT broker port to to open //#define MY_PORT 1883 #define MY_PORT (My_Config.MQTT_Broker_Port) bool loadConfig() { configFile = SPIFFS.open("/config.json", "r"); if (!configFile) { return false; } size_t size = configFile.size(); if (size > 1024) { Serial.println("Config file size is too large"); return false; } // Allocate a buffer to store contents of the file. std::unique_ptr<char[]> buf(new char[size]); configFile.readBytes(buf.get(), size); StaticJsonBuffer<1024> jsonBuffer; JsonObject& json = jsonBuffer.parseObject(buf.get()); if (!json.success()) { Serial.println("Failed to parse config file"); return false; } char MQTTURL[40]; char MQTTPORT[4]; char wlan_sta_ssid[20]; char wlan_sta_passwd[20]; strcpy(wlan_sta_ssid, json["wlan_sta_ssid"]); strcpy(wlan_sta_passwd, json["wlan_sta_passwd"]); strcpy(MQTTURL, json["mqttbrockerurl"]); strcpy(MQTTPORT, json["mqttport"]); My_Config.WLAN_STA_SSID = String(wlan_sta_ssid); My_Config.WLAN_STA_PASSWD = String(wlan_sta_passwd); My_Config.MQTT_Broker_FQDN = String(MQTTURL); My_Config.MQTT_Broker_Port = String(MQTTPORT).toInt(); configFile.close(); jsonBuffer = StaticJsonBuffer<1024>(); return true; } bool startSmartConfig() { WiFi.mode(WIFI_STA); delay(500); // Start SmartConfig if necessary WiFi.beginSmartConfig(); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); if(WiFi.smartConfigDone()) Serial.println("smart Config Done"); } WiFi.stopSmartConfig(); delay(500); WiFi.begin(); return true; } void handleJson() { StaticJsonBuffer<1024> newBuffer; JsonObject& newjson = newBuffer.parseObject(server.arg("plain")); server.sendHeader("Access-Control-Max-Age", "10000"); server.sendHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS"); server.sendHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); if (!newjson.success()) { Serial.println("Failed to parse config file from handleJson 1"); server.send ( 200, "text/json", "{success:false,deviceID:'none'}" ); } else{ configFile = SPIFFS.open("/config.json", "w"); if (!configFile) { Serial.println("Failed to open config file for writing in handleJson 2"); server.send ( 200, "text/json", "{success:false,deviceID:'none'}" ); } else{ newjson.printTo(configFile); configFile.close(); //server.send ( 200, "text/json", "{success:true,deviceID:'bla'}" );*/ server.send ( 200, "text/json", "{ \"success\": \"OK\",\"deviceID\": \""+String(MY_MQTT_CLIENT_ID)+"\" }" ); newBuffer = StaticJsonBuffer<1024>(); } } } void startConfigWebServer() { server.on("/json",handleJson); server.begin(); // Web server start Serial.println("HTTP server started"); } #include <MySensors.h> void before() { Serial.println("Resetting WiFi credentials"); WiFi.disconnect(); ESP.eraseConfig(); //spi_flash_erase_sector(0x7e); if (!SPIFFS.begin()) { Serial.println("Failed to mount file system"); } if(!loadConfig()) { if(startSmartConfig()) { startConfigWebServer(); server.handleClient(); } while(!loadConfig()) { server.handleClient(); } delay(2000); server.stop(); WiFi.disconnect(); ESP.eraseConfig(); // spi_flash_erase_sector(0x7e); //loadConfig(); SPIFFS.end(); ESP.reset(); } else{Serial.println("Config loaded..."); delay(2000); } server.stop(); WiFi.disconnect(); ESP.eraseConfig(); // spi_flash_erase_sector(0x7e); //loadConfig(); SPIFFS.end(); //ESP.reset(); } void setup() { ESP.wdtDisable(); pinMode( button, INPUT_PULLUP ); digitalRead(button) == HIGH; } void presentation() { // Present locally attached sensors here } void loop() { ESP.wdtDisable(); //Serial.println("inside loop"); if ( digitalRead(button) == LOW ) { Serial.println("Resetting WiFi credentials"); SPIFFS.begin(); SPIFFS.remove("/config.json"); SPIFFS.end(); WiFi.disconnect(); ESP.eraseConfig(); spi_flash_erase_sector(0x7e); configExist = false; ESP.restart(); } //Send locally attech sensors data here }
So after a some time I get this esp reset (I tried to put ESP.wdtDisable(); in loop)
this is the serial output:connected with MYSSID, channel 1 dhcp client start... ..ip:192.168.0.113,mask:255.255.255.0,gw:192.168.0.1 .IP: 192.168.0.113 0;255;3;0;9;MCO:BGN:STP 0;255;3;0;9;MCO:BGN:INIT OK,TSP=1 IP: 192.168.0.113 0;255;3;0;9;Attempting MQTT connection... 0;255;3;0;9;MQTT connected 0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/0/0/18 pm open,type:2 0
but after a few seconds (mainly after a message is sent from a sensor...but not only . if I send a message from broker that is not sending via radio to sensor its more stable ) I getting this:
bcn_timout,ap_probe_send_start ap_probe_send over, rest wifi status to disassoc state: 5 -> 0 (1) rm 0 pm close 7 ?)�L®D‚
And its seems that the ESP is resetting itself...
What do you think I can do to make this more stable? maybe add "__yield" some where? (I think to adding of ESP.wdtDisable helped a little at list the reset is with out the long stack message...) -
RE: ESP8266 GW+Node (MQTT Transport): Won't Present Sketch or Actuator To Controller
@non_avg_joe
In the section where needed to populate the params from SPIFFS// Here to be the reading of a json/cbor object from a file on a local storage (e.g. : SPIFFS over Serial NVRAM) & the parsing of it into the My_Config struct My_Config.WLAN_STA_SSID = "My-WLAN"; My_Config.WLAN_STA_PASSWD = "My-Passwd"; My_Config.MQTT_Broker_FQDN = "hercules.local";
Did you ever got to implement this section?
-
RE: Gateway to hands out node ID's
So I went and change the MyTransport.cpp file and added a few lines around line 740:
uint8_t currentID; #if defined(MY_GATEWAY_FEATURE) if (type == I_ID_REQUEST) { currentID = hwReadConfig(0X123); //Read first byte of free conf eeprom space if(currentID==0xFF)//check to see if it was never changed (255)... {currentID = 1;} _msg.set(currentID); if(transportSendWrite(0xFF,_msg)) { hwWriteConfig(0X123,currentID+1) } } else // Hand over message to controller
But the sensor still requesting an ID without getting it...
-
RE: Gateway to hands out node ID's
@hek said:
Why pass it to the sketch? You could implement the id-handout directly in core (I pointed out the area where internal messages directed to the node is processed).
To mess with core as little as I could so it can be easy upgradable in future (I already altered the MyGatewayTransportMQTTClient.cpp to support using dynamic connection parameters instead hard coded , I don't want to alter a lot of core files but if it necessary I will...)
-
RE: Gateway to hands out node ID's
@hek said:
Internal messages does not get exposed in the receive() function of the sketch.
To archive this you would have to modify the core somewhere here:
https://github.com/mysensors/MySensors/blob/development/core/MyTransport.cpp#L706Thanks for answer.
I tried to figure where I change the internal msg type to be exposed to GW in the MyTransport.cpp around line 706 but can't seems to find it... -
RE: Gateway to hands out node ID's
@sundberg84 it's need to be automatic. Fix id is easy to implement but because there will be an unknown number of nodes than I cannot use fix id's...
-
RE: Gateway to hands out node ID's
@tbowmo said:
This is not implemented in the gateway code, as it's "always" been the job of the attached controller.
I know it's "always" been the job of the attached controller but I have a scenario that the mqtt gateway will send directly to a cloud broker and an app that will receive it without any controller on the way. one problem I facing is the nodes id handing...so my question is if I would like to implement this in the GatewayESP8266MQTTClient.ino file is it possible?(check for incoming id request and 255 id number and saving current id handed in gateway eeprom etc...)