@rejoe2 Thanks, I actually have a counter but removed it from the code to keep it simple. It counts the pulses and sends the number for comparison and it matches actually. So the problem is at the beginning with the node "getting false pulses" from the machine. Any idea how that can be explained?
Posts made by MaKin
-
RE: Binary sensor for production counting transmits false values
-
RE: Binary sensor for production counting transmits false values
Thanks for your response. You are perfectly right. The counting happens on the server (counting the transmitted '1's coming via MQTT).
-
Binary sensor for production counting transmits false values
Hey guys,
I am currently working on a project in our company where I would like to use NodeMCU to count produced parts and send the data via MQTT. The NodeMCU is attached to one of the pulse generators (e.g. a cutter or welder) and the NodeMCU receives that signal but it seems like it is counting too many signals (like doubling the real value) and I cannot figure out why.
The highes frequency of pulses (produced parts) I have to deal with are about 2 - 3 per second.
This is my simple binary sketch:
// Enable debug prints to serial monitor #define MY_DEBUG // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h #define MY_BAUD_RATE 9600 #define MY_GATEWAY_MQTT_CLIENT #define MY_GATEWAY_ESP8266 #define MCU_ID redacted // Set MQTT client id #define MY_MQTT_CLIENT_ID MCU_ID // Set this node's subscribe and publish topic prefix #define MY_MQTT_PUBLISH_TOPIC_PREFIX redacted #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX redacted // Enable these if your MQTT broker requires username/password #define MY_MQTT_USER redacted #define MY_MQTT_PASSWORD redacted // Set WIFI SSID and password #define MY_ESP8266_SSID redacted #define MY_ESP8266_PASSWORD redacted // MQTT broker ip address. #define MY_CONTROLLER_URL_ADDRESS redacted // The MQTT broker port to to open #define MY_PORT 1883 #include <ESP8266WiFi.h> #include <MySensors.h> #include <Bounce2.h> #define CHILD_ID 1 #define BUTTON_PIN 3 #define LEDRED 16 #define LEDGREEN 0 Bounce debouncer = Bounce(); int oldValue=-1; MyMessage msg(CHILD_ID,V_STATUS); MyMessage msgCount(CHILD_ID,I_LOG_MESSAGE); MyMessage msgHeartbeat(CHILD_ID,I_HEARTBEAT_RESPONSE); int countHeartbeat = 0; void setup() { // Setup the button pinMode(BUTTON_PIN,INPUT); // Activate internal pull-up digitalWrite(BUTTON_PIN,HIGH); // After setting up the button, setup debouncer debouncer.attach(BUTTON_PIN); debouncer.interval(5); countHeartbeat = 0; //Setup the Pulse LED pinMode(LEDRED, OUTPUT); //Setup the Status LED pinMode(LEDGREEN, OUTPUT); digitalWrite(LEDGREEN, HIGH); } void presentation() { sendSketchInfo(MCU_ID, "1.0"); present(CHILD_ID, S_BINARY); //present(HEARTBEAT_ID, S_BINARY); } // Check if digital input has changed and send in new value void loop() { debouncer.update(); // Get the update value int value = debouncer.read(); countHeartbeat ++; if(countHeartbeat >= 1155000){ //Serial.println("Heartbeat"); send(msgHeartbeat.set(1)); countHeartbeat = 0; } if (value != oldValue) { // Send in the new value send(msg.set(value==HIGH ? 0 : 1)); oldValue = value; if ( value == 1) { //Serial.println("Off"); digitalWrite(LEDRED, LOW); delay(30); } else { //Serial.println("On"); digitalWrite(LEDRED, HIGH); } } //send(heartbeat.set(value==1)); }
I appreciate any hint or comment!
-
RE: Problem with NRF24L01+PA+LNA (Gateway - Sensor Connection)
@gohan Thanks, I will try that!
-
RE: Problem with NRF24L01+PA+LNA (Gateway - Sensor Connection)
We bought these: NRF24L01+ PCB Adapter
We do not use any capacitor.
What irritates me, the gateway works (ethernet gateway) with the +PA+LNA, whereas the sensor nodes do not. We have switched the PCB Adapters and antennas without any change.
-
RE: Problem with NRF24L01+PA+LNA (Gateway - Sensor Connection)
@gohan I bought the voltage regulators for nrf24 and provide 5V, but still...
-
RE: How to get sensor data into influxdb?
@Yveaux do you also use Grafana in order to visualize the data? I am not sure what fields/attributes are necessary despite "time" and "value" for a binary sensor.
-
RE: Problem with NRF24L01+PA+LNA (Gateway - Sensor Connection)
It's weird, as it seems to work for my Gateway, but as soon as my sensors are connected with the +PA+LNA, they cannot register.
-
RE: Problem with NRF24L01+PA+LNA (Gateway - Sensor Connection)
Thanks a lot guys. Can you recommend a suitable power supply? And what capacitator should I get?
And how does the RFM69 compare to the NRF24L01?
-
RE: Problem with NRF24L01+PA+LNA (Gateway - Sensor Connection)
Thanks for your help, once again.
I have only connected it to the Nano's 3.3V port yet.
Unfortunately, I didn't know that disconnecting the antenna might damage the radio. But I did only try it with one of the radios.How should I then connect it properly if the 3.3V is insufficient?
Thanks in advance.
-
Problem with NRF24L01+PA+LNA (Gateway - Sensor Connection)
Hello everyone,
I have just switched from NRF24L01+ to NRF24L01+PA+LNA radio modules and I am currently struggling with establishing a connection between the Gateway and a Sensor.
Gateway (NRF24L01+PA+LNA):
0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.1.1 0;255;3;0;9;TSM:INIT 0;255;3;0;9;TSF:WUR:MS=0 0;255;3;0;9;TSM:INIT:TSP OK 0;255;3;0;9;TSM:INIT:GW MODE 0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0 0;255;3;0;9;MCO:REG:NOT NEEDED IP: 192.168.0.100 0;255;3;0;9;MCO:BGN:STP 0;255;3;0;9;MCO:BGN:INIT OK,TSP=1 IP: 192.168.0.100 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
Sensor Node (NRF24L01+PA+LNA):
0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1 3 TSM:INIT 4 TSF:WUR:MS=0 11 TSM:INIT:TSP OK 12 TSM:INIT:STATID=10 15 TSF:SID:OK,ID=10 16 TSM:FPAR 1615 TSF:MSG:SEND,10-10-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 3624 !TSM:FPAR:NO REPLY 3627 TSM:FPAR 3630 TSF:MSG:SEND,10-10-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 5638 !TSM:FPAR:NO REPLY 5640 TSM:FPAR 5643 TSF:MSG:SEND,10-10-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 7651 !TSM:FPAR:NO REPLY 7653 TSM:FPAR 7656 TSF:MSG:SEND,10-10-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 9664 !TSM:FPAR:FAIL 9665 TSM:FAIL:CNT=1 9667 TSM:FAIL:PDT 19670 TSM:FAIL:RE-INIT
In general: With the NRF24L01+PA+LNA connected to 3V, the serial monitor remains empty from time to time (especially often if the antenna itself is disconnected from the radio module).
Also, when starting the Arduino IDE with the sensor node connected, I receive the following error message:
Error while setting serial port parameters: 115,200 N 8 1
With the NRF24L01 radio module I used before, there is no such problem. The Gateway receives and the sensor sends - as it is supposed to be.
It's really frustrating, because I wanted to enhance the signal strength and now I am left with no communication at all.
I have read that the problem might be the 3.3V supply. Does this problem match the schema?
Thanks in advance.
-
RE: How can I measure/track current pulses from machines?
@mfalkvidd I can have it output in either 12V or 24V - my choice.
I have various SRD-12VDC-SL-C octocoupler relays, but I have no idea how to set it up as a sensor instead of an actuator.
@gohan see my reply to mfalkvidd
I had a look at the Power Meter Pulse Sensor but I am clueless on how to transfer it to my components.
Thanks again for taking the time to help.
-
RE: How can I measure/track current pulses from machines?
@gohan thanks for your input! Can you explain how exactly you would do that? I think I should have some optocoupler in my starter kit - does it have to be some special kind of optocoupler? Can you tell me how to connect the Arduino, Octocoupler and the "machine" I want to measure? Are there mySensor sketches I could work with?
@mfalkvidd thank you too. I just had to do some research on what ttl means and unfortunately, I am not sure whether this true for our machine. Same question here, is there a sample sketch available?
Thank you very much guys. I really appreciate your support.
-
RE: How can I measure/track current pulses from machines?
@gohan said in How can I measure/track current pulses from machines?:
You could use node-red to route data to any database if you like.
Thanks for the info. I already had a look at node-red but so far, I am satisfied with the myController interface for influxDB.
-
RE: How can I measure/track current pulses from machines?
@mfalkvidd said in How can I measure/track current pulses from machines?:
@MaKin have you looked at https://www.mysensors.org/build/pulse_power ? Not that I want to ruin your learning experience at school, but it sounds pretty similar to that example.
You're absolutely not. Thanks a lot. But am I right to use a relay instead of the light sensor? Because in mysensors relays are (obviously) used as actuators.
-
How can I measure/track current pulses from machines?
Hello everyone,
for a student's project, I have to find a way to track current impulses from a machine, so that I can record the times that impulses were triggered in a given time (e.g. per hour). Unfortunately I am no electrical engineer and therefore struggle with the hardware side, which is why I came to you guys after searching the Internet (which is pretty difficult if you do not really know the terms to search for ).
What I have though so far: Using a relay module, connecting the "machine" to the Arduino with the relay in between and logging the impulses with the binary sensor. Does that make any sense to you?
The analysis part including Grafana and influxDB is easy peasy, but I have to get that far in the first place.
I would really appreciate your help with this as it really is frustrating.
So far, I managed to do everything I wanted with mysensors and help I found here, but this time I am overstrained...
Thanks in advance,
MaKin
-
RE: How to get sensor data into influxdb?
I have just discovered that there is an option for external servers like influxdb in mycontrollers. Can you say something about it compared to red node?
And thanks for the code!
-
RE: How to get sensor data into influxdb?
Thanks a lot and yes please, that'd be very helpful!
-
How to get sensor data into influxdb?
Hey guys,
I am running several sensors (mysensors) and would like to push them into an influxDB instance in order to visualize it with Grafana.
Influxdb and Grafana are already running on my Pi3 but I'm not sure what is the most elegant and easy way to push the data into the database.
Any hint is appreciated.
-
Error decoding message from gateway, probably received bad byte.
Hello everyone,
I wanted to implement MySensors with HASS as a students project. I already have it running at home and it works flawlessly. But now I cannot overcome the following error:
mysensors.mysensors: Error decoding message from gateway, probably received bad byte.
I've never had such an error before. I tried using the combination of Arduino-Gateway and Arduino-DHT22 AND I also tried to have both on the same Arduino (both ways worked with my sketches at home).
I also tried to install pyserial 2.5 as it was stated in another thread.
Do you guys have any idea what else I could try?
-
RE: CDS - Cat Defense System (Arduino + Servo + Motion Sensor)
@Tetnobic yep, thanks.
Is there one you'd recommend?
-
RE: CDS - Cat Defense System (Arduino + Servo + Motion Sensor)
Good to know but 40€, that is very much for a sensor can. And it's less fun.
-
CDS - Cat Defense System (Arduino + Servo + Motion Sensor)
Hey guys,
as our cat tries to drive us crazy for a while now and as my wife is pregnant and should get a little sleep as long as she can, I thought about building some kind of Cat Defense System consisting of a spray bottle filled with water, an arduino, a MG996R Servo and a HC-SR501 PIR motion sensor.
Will keep you updated.
-
RE: Node 0 unknown, error decoding message from gateway
Just saw that myself. Thanks once again. I'm starting to feel embarrassed...
-
RE: Node 0 unknown, error decoding message from gateway
But my Sketch name is SerialGateWayDHT22 and my sensors are called sensor.temperatureandhumidity_0_0 and sensor.temperatureandhumidity_0_1. If it was the Sketchname, it was much simpler to assign the sensors to the rooms later as I could simply name the switch after the room.
But it's not much of a problem, as like you said friendly names can be used.
-
RE: Node 0 unknown, error decoding message from gateway
@martinhjelmare thank you so much for your help.
Is there a way to declare sensor names so that HA receives a presentation with something like
mysensors.livingroom.temp
Instead of a more cryptic name with node_id?
-
RE: Node 0 unknown, error decoding message from gateway
@martinhjelmare said:
presentation();
I'll try that. Thanks.
Now this error remains:
16-12-17 21:58:00 mysensors.mysensors: Error decoding message from gateway, bad data received: T: 23.90 16-12-17 21:58:00 mysensors.mysensors: Error decoding message from gateway, bad data received: H: 49.30 16-12-17 21:58:02 mysensors.mysensors: Error decoding message from gateway, bad data received: T: 24.00 16-12-17 21:58:14 mysensors.mysensors: Error decoding message from gateway, bad data received: T: 23.90
But the sensors are listed in HASS:
sensor.temperatureandhumidity_0_0:
friendly_name: TemperatureAndHumidity 0 0 V_HUM: 49.2 node_id: 0 device: /dev/ttyACM0 battery_level: 0 description: child_id: 0 unit_of_measurement: %
-
RE: Node 0 unknown, error decoding message from gateway
How would you do that? You can see my sketch above.
-
RE: Node 0 unknown, error decoding message from gateway
Now it's not about the node 0 but the children.
16-12-17 11:39:31 mysensors.mysensors: Child 1 is unknown 16-12-17 11:39:31 mysensors.mysensors: Error decoding message from gateway, bad data received: T: 22.50 16-12-17 11:39:31 mysensors.mysensors: Child 0 is unknown 16-12-17 11:39:31 mysensors.mysensors: Error decoding message from gateway, bad data received: H: 40.20
The serial monitor shows me the following:
0;255;3;0;9;Starting gateway (R-NGA-, 2.0.0) 0;255;3;0;14;Gateway startup complete. 0;255;0;0;18;2.0.0 0;255;3;0;9;No registration required 0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1 0;1;1;0;0;23.2 T: 23.20 0;0;1;0;1;44.5 H: 44.50 0;0;1;0;1;44.4
Is anything wrong with my sketch? I hacked it together...
// Enable debug prints #define MY_DEBUG // Enable and select radio type attached //#define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 //#define MY_RS485 // Enable serial gateway #define MY_GATEWAY_SERIAL // Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender) #if F_CPU == 8000000L #define MY_BAUD_RATE 38400 #endif // Flash leds on rx/tx/err #define MY_LEDS_BLINKING_FEATURE // Set blinking period #define MY_DEFAULT_LED_BLINK_PERIOD 300 // Inverses the behavior of leds //#define MY_WITH_LEDS_BLINKING_INVERSE // Enable inclusion mode #define MY_INCLUSION_MODE_FEATURE // Enable Inclusion mode button on gateway #define MY_INCLUSION_BUTTON_FEATURE // Inverses behavior of inclusion button (if using external pullup) //#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP // Set inclusion mode duration (in seconds) #define MY_INCLUSION_MODE_DURATION 60 // Digital pin used for inclusion mode button #define MY_INCLUSION_MODE_BUTTON_PIN 3 // Uncomment to override default HW configurations //#define MY_DEFAULT_ERR_LED_PIN 4 // Error led pin #define MY_DEFAULT_RX_LED_PIN 11 // Receive led pin //#define MY_DEFAULT_TX_LED_PIN 5 // the PCB, on board LED #define MY_DEBUG #include <SPI.h> #include <MySensors.h> #include <DHT.h> // Set this to the pin you connected the DHT's data pin to #define DHT_DATA_PIN 3 // Set this offset if the sensor has a permanent small offset to the real temperatures #define SENSOR_TEMP_OFFSET 0 // Sleep time between sensor updates (in milliseconds) // Must be >1000ms for DHT22 and >2000ms for DHT11 static const uint64_t UPDATE_INTERVAL = 2500; // Force sending an update of the temperature after n sensor reads, so a controller showing the // timestamp of the last update doesn't show something like 3 hours in the unlikely case, that // the value didn't change since; // i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms] static const uint8_t FORCE_UPDATE_N_READS = 10; #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 float lastTemp; float lastHum; uint8_t nNoUpdatesTemp; uint8_t nNoUpdatesHum; bool metric = true; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); DHT dht; void presentation() { // Send the sketch version information to the gateway sendSketchInfo("TemperatureAndHumidity", "1.1"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); metric = getConfig().isMetric; } void setup() { present(255, 18); dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) { Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!"); } // Sleep for the time of the minimum sampling period to give the sensor time to power up // (otherwise, timeout errors might occure for the first reading) sleep(dht.getMinimumSamplingPeriod()); } void loop() { // Force reading sensor, so it works also after sleep() dht.readSensor(true); // Get temperature from DHT library float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT!"); } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) { // Only send temperature if it changed since the last measurement or if we didn't send an update for n times lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } // Reset no updates counter nNoUpdatesTemp = 0; temperature += SENSOR_TEMP_OFFSET; send(msgTemp.set(temperature, 1)); #ifdef MY_DEBUG Serial.print("T: "); Serial.println(temperature); #endif } else { // Increase no update counter if the temperature stayed the same nNoUpdatesTemp++; } // Get humidity from DHT library float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) { // Only send humidity if it changed since the last measurement or if we didn't send an update for n times lastHum = humidity; // Reset no updates counter nNoUpdatesHum = 0; send(msgHum.set(humidity, 1)); #ifdef MY_DEBUG Serial.print("H: "); Serial.println(humidity); #endif } else { // Increase no update counter if the humidity stayed the same nNoUpdatesHum++; } // Sleep for a while to save energy sleep(UPDATE_INTERVAL); }
-
Node 0 unknown, error decoding message from gateway
Hey guys,
I have just set up the gateway (also running a DHT22 sensor on the same arduino) in home-assistent and I keep getting the following errors:
16-12-16 16:49:38 mysensors.mysensors: Node 0 is unknown 16-12-16 16:49:38 mysensors.mysensors: Error decoding message from gateway, bad data received: T: 23.00
My config looks like the following:
mysensors: gateways: - device: '/dev/ttyACM0' # persistence_file: 'path/mysensors2.json' baud_rate: 115200 debug: true optimistic: false persistence: true retain: true version: 2.0
As you can see above, the values are received which is great.
Any idea how to solve that?
-
RE: Where do you place your sensors or how do you hide them (case)?
@mfalkvidd yep, found that too. But when using CO2 sensors it doesn't really matter anyway.
-
RE: Where do you place your sensors or how do you hide them (case)?
@mfalkvidd I really appreciate your help and once again it really brought me closer to my goal.
Today I received my arduino uno, some LEDs, resistors, buttons, buzzers and motion sensors and I was able to fiddle around a bit.
Loaded the serial gateway program onto it and added the motion detection part and it seems to work so far. I'm still waiting for my Nanos, radios and DHT22 sensors so I can place them in my rooms.
Can I set the voltage to 3.3V and the clock speed of the Nano to 8Mhz and also use it with a battery (when no CO2 sensor is used)?
-
RE: Where do you place your sensors or how do you hide them (case)?
I don't want you to think I haven't informed myself before. I knew that Uno and Nano are 3.3V and 5V while the Mini Pro is either or. From the getting started I got that I need some kind of step-up or step-down regulator (that's your logic level shifter I assume: here I have to dig deeper into the matter).
What I wasn't and still am not sure about it the computation power. The Mini Pro is 8Mhz with 3.3V and 16Mhz with 5V, therefore optimal for battery usage. But is it the same with the uno and nano?
Or are all the boards the same except for voltage, USB port and form factor?
And don't I have to fear a lack of computation power with multiple sensors being used?
Thanks again for your patience and support, it's unbelievably helpful when entering new fields.
-
RE: Where do you place your sensors or how do you hide them (case)?
Thanks a lot for your replies guys!
So I might also just build two sensor boxes wired when using the CO2 component and wouldn't have to worry about the battery.
When using a CO2 sensor plus the DHT22, should I better take an Arduino Uno/Nano instead of the Mini Pro? And what power adapter would you recommend?
I'm really sorry for asking those questions that might seem so simple to you but my knowledge about electricity is horribly lacking...
I really have to dive deeper into the topic but I'm still pretty fresh to the subject.
-
RE: Where do you place your sensors or how do you hide them (case)?
I ordered the DHT22 for humidity and temperature. Doesn't the Arduino get warm enough to have an impact on the measured environment inside the box?
I'd also like to measure CO2 in the bedroom as we're expecting our first child and I want to make sure the air quality is as good as possible.
-
RE: Where do you place your sensors or how do you hide them (case)?
Thanks a lot guys. Will have a look at these.
Can you tell me how to handle the sensor probes themselves? Can they rest inside the case of will it render the sensor data useless?
-
Where do you place your sensors or how do you hide them (case)?
Hey everyone,
I recently stumbled upon mySensors after playing around with home-assistant for quite some time.
The next thing I wanted to do is measuring temperature, humidity and air quality (CO2) and I am so glad I found mySensors.org.One thing that I ask myself when seeing all your crazy hacks is this:
Where do you hide all the components and where do you place your sensors? I don't really want to have all the cables, sensors and Arduinos to be visible. And compared to the Pi, there aren't that many cases on the market and let's be honest - they're ugly as the night...
But even when putting the components into a case, what about the sensors? I could imagine that it isn't that great to measure the parameters mentioned above INSIDE a case, right?
As I am still waiting for my hardware to arrive - I thought I could beginn my membership here with a quite general questions.
I am looking forward to hearing from you.