"Usually" is the correct term. You can request whatever you want using MQTT, but you need to handle the response manually inside the receive() function. This isn't an automatic internal process like the echo or ack response.
void receive(const MyMessage &message)
{
if (message.getCommand() == C_REQ)
{
switch (message.getSensor())
{
case 10:
// Send SSR 1 state
break;
case 11:
// Send SSR 2 state
break;
case 20:
// Send temperature sensor value
break;
case 40:
// Send humidity sensor value
break;
default:
break;
}
}
}
Note: It's best to not send a message from within receive() as it can cause all sorts of weird stuff, including recursive loops. Preferably, you'd set a flag and handle everything else in the main loop.
I have both the uCurrent gold as suggested by @evb and also the "current ranger" https://lowpowerlab.com/shop/product/152 which is my first choice. It has a small display which makes it easier to use. But both are great products based on the same ideas from Evblog. Then to measure transient current you can hook up an oscilloscope to the output of any of the two.
@evb To get the SNR to the ballpark you'll need to do the following.....
Tune to a frequency close to the one you want that has no signal.
Click the cog or three horizontal lines top left (if using the latter then click 'radio'.
Select 'sensitive' and move the gain slider all the way to the left.
To the right of the spectrum display adjust the 'offset' so that you can see the noise at the bottom of the spectrum display.
Move the gain slider to the right until the noise floor jumps up about 5dB using the scale on the left of the display.
Tune to a constant signal and contimue to move the gain slider to the right. Use your eyes and ears to detect changes in the sound of the signal. You want it as clear as possible. The verticla blue graph on the right of the spectrum display will show signal to noise ratio. It takes a little while to catch up with you so work slowly. Eventually you will get good signal to noise ratio with a high signal to noise ration.
Often as the gain goes higher the noise floor increases and this will degrade the signal, hence the need to find the 'sweet spot' where the signal benefits most from the gain amp whilst the noise is still at a low level.
Hope that makes sense. Any touble and I will try and ecplain it differently.
You are amining for the biggest gap between signal peak and noise.
@alexsh1 Thanks for the comment, there is some good tips there! I'll try re-soldering some of the connections. Funnily enough, I had wanted to increase the transmission power on 2 of my nodes (the furthest away from the controller) including this one here, and had added that at the top of my sketch. After uploading the sketch, the serial monitor still displayed a lot of garbage, but the node started successfully transmitting temperature and humidity values!
So I've put the batteries back in and hung it up in the room, and it has been running pretty good so far. But I have my doubts how long it will last, given I didn't actually fix the serial output issue...
On another note, is there anyway to confirm that the transmission power has been increased? I added
#define MY_RF24_PA_LEVEL RF24_PA_MAX
at the top of my sketch, just after defining the radio type, but it doesn't seem to have improved my transmission success rate (I realise there are lot of other factors affecting transmission success, but just wanted to check)...
@3nibble
Diode is bad.
You can shorting it.
But then you can power this Arduino only from USB or from +5V in the same time!!!
Not both !!! This can damage your USB port.