Really struggling with this code, I can barely follow the flow. The interrupt doesn’t seem to be happening at all as p in the loop is always 0 and I know I was getting data on the interrupt pin as with the previous code I was managing to get data.
Aaarrgh.
@bayesp, you forgot one little bit:
NOTE:
pinMode()
MUST be called prior to calling attachInterrupt() to set the desired mode for the interrupt pin (INPUT, INPUT_PULLUP or INPUT_PULLDOWN).
If the radio board output is not floating then you can set the pinMode() to INPUT.
BTW, you should flash the D7 LED in the ISR by first setting D7 as an output in setup() and then in the ISR add:
digitalWriteFast(D7, !pinReadFast(D7));
This will change the state of the D7 led every time the ISR gets called. In theory, it should blink whenever bits are coming out of the radio module.
Thanks yet again.
The led is flickering on and off so fast it looks like its permanently on, even with the pin mode as PULLDOWN or PULLDOWN. It should only be receiving data every 14 seconds, so possibly interference but I am not certain.
At least it is passing through to the oscv3 conditional in the loop, but still no data.
@bayesp, the flickering may be due to noise or, more likely, it is the carrier signal produced by the Manchester encoding. Hate to ask but do you have an oscilloscope? If not, add some Serial.print() statements in reportSerial()
to first see if it is called and also to see if the data is being decoded. Make sure to uncomment these lines:
for (byte i = 0; i < pos; ++i) {
Serial.print(data[i] >> 4, HEX); <--- uncomment
Serial.print(data[i] & 0x0F, HEX); <--- uncomment
}
Thanks. I don’t have an oscilloscope any more.I did a lot of hardware work years ago but my work took me in more of a technical management role. I can’t do serial.print as I am working from a work laptop that I cant attach anything to USB ports or install software so am reliant on the online IDE. I will have publish to the cloud and look at the console to debug. I am now about to put the children to bed so it will be tomorrow.
I’m not sure I would see the carrier all the time as the sensors only transmit periodically 14s for the anenometer and 1 minute for the thermometer. I’ll let you know how I get on.
HI
Definitely getting to reportSerial() and it is It is constantly receiving data but the first byte is never the correct first byte for the sensors I have, so it never gets any further.
Seems more and more like noise or faulty hardware. I’ll do some checking of the wiring and noise sources, maybe move it ti another room, otherwise, I am stuck.
OK, I feel a bit silly writing this but, I got it working well with the original code I as using. The issue may have been down to grounding. The RF receiver has 2 ground and 2 VCC pins. They are supposedly joined together on the board and all the setups I have seen have said you only need to connect one. I just thought I would try connecting both and lo and behold, it works. I had a bit of an issue publishing some of the values, but this was mainly down to types, although there were no errors, publishing a byte cast to a string always resulted in 0. I changed the types to Long and they are fine.
The hardware still falls over if I try and publish 2 events, one for temp and one for wind but I can get around this by wrapping them both up in one JSON blob.
I also came across something that is probably already well known, but I thought i would mention, if your WiFi SSID has special characters, the photon will not connect. I had to change my APs SSID.
Thanks for all your help and sorry fo wasting your time. I have learnt a lot throughout this so not a total waste.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.