@NeverDie I am happy to report that my batteries arrived yesterday!

OldSurferDude
@OldSurferDude
Best posts made by OldSurferDude
-
RE: What's a good power bank for use with IoT?
-
RE: What's a good power bank for use with IoT?
@NeverDie
I'm going to dissipate the energy through a 25 ohm resistor. It will take about 24 hours to perform one capacity test. Often times I read that the full capacity won't be available until after a few charge-discharge cycles. 2 resistors, 4 batteries, 3 tests each. Assuming that I stay on top of it, it will take at least a week of testing which won't start until I get my 25 ohm resistors. I'll post a link to my full write up. -
RE: What's a good power bank for use with IoT?
OK, I did my battery test. @NeverDie @Nca78 @mfalkvidd
You can find it hereThe batteries from Newegg and Fullbattery are good ones.
If you going to buy a large quantity and looking for a low price, then you should buy 1 or two and test them as I have done here. You might have to "kiss a lot of toads" before you find a good vendor, though.
OSD
-
RE: Saving last known good state, but not in EEPROM
@eiten said in Saving last known good state, but not in EEPROM:
This is exactly what I am seeking! Thank you!
PS I truly enjoy reverse translating! It teaches me how to better understand my first language and it gives me alternate words to use in searches. So a second thank you!
"Regelmässiges Zurücksetzen" would be best translated to English in this context as "Periodic Reset". In the English version of Home Assistant it is called "Meter reset cycle" (I remember seeing "keep dry" translated as "do not take in shower with you"
-
RE: Beginner concept question for serial communication
@hubertus I'm not getting the description of you setup. Perhaps a sketch would be good?
Wen I need serial communication, with the Arduino, I use SoftwareSerial on two other I/O lines. That way I can debug real time, SoftwareSerial is slower but you're only doing temperature so 9600BAUD would be fin
Also, don't try to do too much at once. Break the task down into small, manageable sections. You have a lot of different things going on, get one thing going at a time.
OSD
-
RE: What's a good power bank for use with IoT?
@NeverDie I like your suggestion for solar panels, though my application only requires 1x 5W panel. And I like the idea of dismantling the power packs.
I think we differ in our approaches, though. I seem to enjoy living on the "bleeding edge", that is, I'm more of a risk taker. My first house solar system, 2.8kW, was installed in 2004. When I upgraded to 4.2kW, I took the 14 panels and installed them on my hillside, so now I'm a net energy exporter. The 2.8kW portion is still producing at 85% of nameplate, shows little environmental degradation (sealant, too), and has paid for itself. The reward outweighed the risk.
In taking risks, I learn much. Yes, I have a quite a few scars, actually and metaphorically. I have discovered a philosophy: Everything is an experiment. The point of an experiment is to learn something. So every experiment is a successful, just that sometimes the desired results are not realized. Eg. leaving an Arduino outdoors results in a short useful life. Spraying on a sealant extends the outdoor life.
Good discussion. Thanks for the ideas
OSD
-
RE: Where did everyone go?
I'm new-ish to MySensors. I came here because I was looking for a gateway from RF24 to MQTT and I'm well on my way to getting the MySensors version to work.
Why isn't MySensors working? I find two things really frustrating. The documentation is spotty at best. It's taking me days to get as far as I have. When I write up my own procedure for my own documentation, I find it's maybe just 20 steps, but each step needs a detailed explanation. For example, through a lot of trial and error, I found that to turn on the relay in the relay with button example I had to publish a message of 1 to the MQTT topic mysensors-in/13/1/V_LIGHT/0/2. Only later did I find the Serial Protocol 2.x. But it does't show a V_LIGHT nor S_LIGHT. Yes, I figured out that example is out of date, but that's part of the point I'm trying to make. And how did my node ID become 13 and stay 13 when I press reset on the Arduino?
You can see more detail on my frustrations in the MQTT gateway discussion
Which segues into my other frustration. about documentation. Many members offering advice do not provide links to their statements. For example, in the MQTT gateway discussion:
gohangohan MOD 3 Sept 2017, 13:15
(at)Richard-van-der-Plas "Just clone the 2.2 dev instead of the stable, the rest is the same
(emphasis mine)How does one do that? Particularly in a world where case is important and there are three different quote marks, (excuse me, one is sometimes known as a gravé) all with different meanings.
There are many like you @NeverDie who know MySensors in-and-out. I am an experienced hardware and software engineer, retired (one of the engineers that developed ink jet printing and one of the engineers that developed a navigation system for the 747) It's not like I don't have a fundamental understanding of what's going on here. I have yet to find a way to search the forum other than using google search.
Don't get me wrong, the MySensors concept is great and functions pretty well, but if it's not well documented, then it is useless. Then when someone asks a simple questions only to get an answer with no explanation of the how, the newbie and experienced alike don't bother with the forum because the forum offers no help, either.
We had a poster at HP (when it was a great company) "No job is done until the paperwork is complete" (image of person sitting on the toilet)
-
RE: What did you build today (Pictures) ?
@NeverDie It is my understanding, though I can't wrap my head around it, that it is the length of the conductor that makes the antenna tuned to a certain frequency. If this is the case, you could run your antenna around the edge of your circular pcb which would make the effective radius only slightly bigger.
-
RE: How to optimise a code (95% memory used)
I found that timelib.h uses a tremendous amount of memory. You avoid using it by getting time string from the controller.
I have also found that when you're using that amount of memory that bad things happen, as you noted. I use global variables to avoid the transient nature of function variables.
I'll be looking forward to other comments as, I, too, do not know all the tricks;)
OSD
-
RE: What I must buy in order to measure mAh please
@DenisJ Are you measuring a USB device? Look at something like this https://www.aliexpress.com/item/33019457512.html?gps-id=pcDetail404&scm=1007.16891.96945.0&scm_id=1007.16891.96945.0&scm-url=1007.16891.96945.0&pvid=824c24fa-034b-4801-b51d-50b2ad877945&_t=gps-id:pcDetail404,scm-url:1007.16891.96945.0,pvid:824c24fa-034b-4801-b51d-50b2ad877945,tpp_buckets:668%230%23131923%2330_668%230%23131923%2330_668%23888%233325%239_668%23888%233325%239_668%232846%238110%231995_668%232717%237561%23332__668%233374%2315176%2335_668%232846%238110%231995_668%232717%237561%23332_668%233164%239976%23761_668%233374%2315176%2335
(AliExpress: Cheap prices and one could question the quality, but for the most part they work. Shipping takes about a month. rarely faster)
Latest posts made by OldSurferDude
-
RE: Ghost Child
I want to thank @FcNanoLed. I had long thought about a serial gateway. This would be a way to add I/O to a linux computer. In the process of trying to help, I built up a linux machine running virtual box. In the virtual machine I ran Home Assistant The not well documented part of that was to connect the USB port of the computer to the virtual machine (settings-->USB-->USB Device Filters) (note that one can buy a refurbished PC for about the same price as an equivalently configured RPi)
So thanks for the inspiration!
-
RE: ESPnow as transport layer
@MasMat I won't say I'm better informed, as I just scanned some of the documentation. It seems that ESPnow combines many of the OSI layers. These layers exist for a reason and adnerence to them allows for the extent of the internet.
That said, we don't want our IoT devices to be part of the internet. The low overhead of MySensors communication is required for MySensors to run on Arduinos and inexpensive radios.
Espressif combines theses two at a lower cost. I need to look into it!
I found Getting Started with ESP-NOW (ESP32 with Arduino IDE) It's mesh is limited to 20 devices. MySensors is theoretically limited to 254, but in practice my experience indicates about 30.
I have found the Arduino Nano and the nRF24 very robost, though the tolerances on the radio make it "wabbly" Again, my experience, the ESP8266 is a little fragile (smoked a few) though the radio is awesome.
I have a project I call The Universal Light Switch. My alpha testing is 20 ESP8266 devices Which uses 20 IP addresses on my router. I discovered that my home routers can only handle about 25 WiFi devices. So ESPnow has my attention.
-
RE: Ghost Child
I saw that, too, but I wasn't sure. This is documented here
bool present(uint8_t childSensorId, uint8_t sensorType, const char *description, bool echo);
-
RE: Ghost Child
@FcNanoLed
I have not used a configuration where a Nano is connected directly to the controller. I assume your program has
#define MY_GATEWAY_SERIAL
because I when I compiled a sample program without it and without a radio I got the error:
#error No forward link or gateway feature activated. This means nowhere to send messages! Pretty pointless.
Your code is probably right, but if you posted the entirety we may be able to find the error. Are CHILD_ID_ARMED, and the IDX_xxxx variables? If this is the case, something could be changing them, which could create the ghosts. Typically, compiler directives are used, eg.
#define CHILD_ID_ARMED 0 #define IDX_PORTAIL2 123
I can't think of anything else right now
-OSD
-
Home Assistant/MySensors quirks
I just deployed my Remote Solar (with battery) Moisture Sensor. Once I got all of the subtilties nailed down, two lines of code, read and send, bloomed into over 300 lines!
There were three Home Assistant (HA) related gotchas.
Gotcha 1. getting data from HA.
If you have everything coded right, HA will know about your Arduino, but you have to send a datum for each sensor (child_ids) to get HA to know about the sensors. I do this in setup
But for reasons beyond my understanding, HA won't send anything other than binary. To get around this I send text. That is, the
MyMessage
is of typeV_TEXT
and thepresentation()
isS_INFO
#define CHILD_ID_SAMPLE_INTERVAL 0 MyMessage msgSampleInterval(CHILD_ID_SAMPLE_INTERVAL, V_TEXT); volatile unsigned long SamplePeriod = 20000; // ms to sleep between sensor reads volatile bool SamplePeriodReceived = false; void presentation(){ present(CHILD_ID_SAMPLE_INTERVAL,S_INFO,varName); // sensor 0 wait(REGISTERING_VARIABLES_WAIT); } void setup(){ send(msgSampleInterval.set(SamplePeriod)); wait(MESSAGE_WAIT); } void loop(){ // read data // send data if (SamplePeriodReceived) { SamplePeriodReceived = false; // do something with datum that came from HA } smartSleep(SamplePeriod); } void receive(const MyMessage &message){ switch( message.getSensor() ) { case CHILD_ID_SAMPLE_INTERVAL: // MQTT topic: mysensors-in/177/0/0/0/47 SamplePeriod = message.getLong(); SamplePeriodReceived = true; break; }
What's going on?
- Basic
MyMessage
, but of type V_TEXT - The two variables need to volatile because they can be changed at any time by the background process
receive()
. This variable must be kept up-to-date. present()
is of type S_INFO (see below forvarname)- Send an initial value in
setup()
so that HA knows about the variable - In
loop()
, check periodically to see if a datum came in. This is done because you want to keep thereceive()
routine as short as possible. Also, no sends and no print statements, no long loops, etc. inreceive()
. Anything you can do inloop()
, do it inloop()
.
The data is sent from HA as text. Doesn't matter, the message.getTYPE(); will convert it for you.
Gotcha 2. I use an MQTT gateway. I have a
wait()
after everysend()
. I'm not sure why; my guess is that if you send to fast, the data gets overrun. For sending messages, I use 300mSec. For presentation is use 4000 mSec!!!!Gotch 3. Beauteous! I got it all working. Time to turn
MY_DEBUG
off. To ensure it is off:#ifdef MY_DEBUG #undef MY_DEBUG #endif
It stopped working and, because
MY_DEBUG
was off, I couldn't figure out why. I put it back in, worked fine. It dawned on me that those debug statements took time. I added 200mSec, yes, a full half second! (Lieutenant Commander Data: 0.68 seconds sir. For an android, that is nearly an eternity.)Do not use
delay()
, that stops all processing.wait()
will allow the background process to function, such as receiving data. The syntax forwait()
isbool wait(unsigned long ms, uint8_t cmd, uint8_t msgtype);
which will wait for the first condition to be true, but I am unable to find the cmd or msgtype. To wait for those would be much more elegant.- below
varname
varname This is the name that HA uses in automations, scripts, etc. The problem comes when you have two Arduinos that run the same code. HA appends an arbitrary number to the end of the variable name. This leaves you to root around HA to find out what that was. I programatically append the node number to my varname. varname must be of type
string
(an array of characters the byte after the last character set to 0) as opposed to typeString
. Using typeString
is not advised as it is very easy to add to the String so much that it wipes out memory beyond its bounds. A real bugger to debug, especially if it occurs inreceive()
.- HA script to change interval period to 4001 mSec (assumes varname is "int177"
sequence: - target: entity_id: text.int177 data: value: "4001" action: text.set_value alias: moisture sensor 177 Sample Period 4001 HA mode: single description: Send text to change sample period to 4001
- Basic
-
RE: Ghost Child
@FcNanoLed I'm a Home Assistant (HA) user so I don't know if this is applicable to you.
I am assuming here, because your nano is connected to your RPi through a USB port that your nano is running MySensors Gateway code. I believe that both gateway and node code has to have a radio connected to start. So I assume this, too.
The source could be an errant RF signal caused this, though unlikely.
Ghost devices in HA also show up when a device gets assigned a new node on a reboot, or were deleted improperly, eg. not deleted using the controller environment.
In either case, what has to be done in HA is basically remove all vestiges of the MySensors environment best you can.
- Ensure that the code on the device(s) that has the sensors (child) is(are) working properly
- Power down this(these) device(s)
- if you have a gateway, stop or power it down
- Delete this(these) device(s) from the host program
- Delete the integration (this is what the code running in the Controller is called in HA)
- If you use MQTT, use a program like MQTT Explorer to remove all vestiges of MySensors.
- reboot the Controller (HA in my case)
- reinstall the integration
- restart the gateway
- At this point you may still see the ghost!
** list itemFor each ghost, create a device that looks like the ghost then delete it using the controller interface.
** Then reboot the host again. - finally reconnect all of your valid devices.
Yes, it is a pain in the ***! Has a lot to do with recoving after a power failure, backups and trying to accomodate all possible scenarios.
Hope this helps
-OSD
-
RE: Door chime
@Paul-Scarbro There are multitude of solution, but since we are in MySensors Land, let's do a MySensors solution. You'll quickly see that doing that adds a lot of overhead.
We'll use an Arduino Nano or RF Nano if you're going to go whole hog. It can be run from 3.3V or 5V DC, not AC.
The reed switch would be connected to an input of the Nano and one of the outputs would drive a relay. The relay would drive the chime.
Your C++ program would be something like:
#define inputButton 2; // connect reed switch here #define outputRelay 4; // connect relay to this pin see MySensors Relay example #define RELAY_ON 1 // GPIO value to write to turn on attached relay #define RELAY_OFF 0 // GPIO value to write to turn off attached relay void setup() { pinmode(inputButton,INPUT); pinmode(outputRelay,OUTPUT); // put your setup code here, to run once: } void loop() { // put your main code here, to run repeatedly: if (digitalRead(inputButton) == 0) { digitalWrite(outputRelay,RELAY_ON); wait(2000); // wait 2 seconds digitalWrite(outputRelay,RELAY_OFF); // now wait for door to close while(digitalRead(inputButton) == 0) ; //does nothing until reed switch opens } }
There are some subtleties that I may have glossed over, but this is the gist.
By looking at the MySensors Relay example, you'll see how to integrate this into a MySensors environment. That's where you'd want to get the RF Nano.
I've made the assumption you're familiar with the Arduino IDE and you've looked into the MySensors environment.
-
RE: MQTT-Help me understand about the MQTT Gateway.
@dpcons MQTT sounds intimidating and looks imitimidating when you see all of the options available.
Here's the scenario:
- You want to send a message. That's the -m option followed by a space and the message between " "
- the location, topic, is a tree, -t option, separated by forward slash / eg. MyRootTopic/MyTopicsSub/MyTopicSubSub
It's as easy as that if your broker, the MQTT service (program) is on the same computer as the sending program. Usually it's not.
- Specifiy the location, the host, of the broker with the -h option followed by the host name or IP address
The retain option, -r is important but explaining it is beyone the scope of this message
Receiving, subscribing, to a topic is just the same, but you wouldn't have the -m message
If you subscribe from the command line, the subscribe function waits indefinitely for messages published to the subscribed topic (unless you use the -C option) ^C to terminate the command.
A tamotized device with the MQTT configured will create a number of topics on the broker. Home Assistant will see this automatically, if you have the Tasmota and MQTT Integrations installed.
The MySensors MQTT gateway takes care of MQTT communication for a MySensors device. Again the MySensors and MQTT integrations.
I use both.
-OSD
-
RE: MQTT-Help me understand about the MQTT Gateway.
@dpcons that is correct. The ESP communicates directly with the MQTT broker.
It's very easy if you're ESP has been Tasmotized. I am of the understanding that one can compile their own Tasmota binary to suit particular needs. I have not done this.
If you're using the Arduino IDE to program your ESP, it is possible to communicate directly to the MQTT broker. You will have to come up with your own protocol though, This I have done and it takes some perseverence.
Both Tasmota and Arduino IDE accomodate Over-The-Air (OTA) updates. This is nice, especially when your device is behind a panel or up the hill. Interestingly enough, if something is Tasmotized, an Arduino IDE binary can replace it OTA; and vice versa. This I have done many times. (Yes, some failures to communicate and a hike up the hill
-
RE: MQTT-Help me understand about the MQTT Gateway.
@dpcons All the esp8266 devices with which I have experience have WiFi and can be Tasmotized. Fundamental to Tasmota is to WiFi; you specify the SSID and passphrase. Also fundamental to Tasmota is connecting to an MQTT broker; you supply IP address and, if necessary, name and password. In addition, there exists DHTxx configurations. Load this software and your data is going to the broker.
(Home Assistant has an integration for Tasmota whch requires the MQTT integration.)
I have done this many times and for me it takes less time that it did to write this response to get a DHT12 putting data to the broker. Tasmota is incredibly well supported, so it shouldn't take you much longer.
I make the assumption that you already have a way to program the esp8266. The process to which I refer ggoes something like this:
- Put your esp8266 in the programmer
- connect your programmer to a usb port of the your computer
- open the tasmota web installer
- In following the istructions, be sure to do the load SSID/passphrase, if you don't you'll have to connect to your esp8266 over WiFi (http://192.168.4.1) and enter them on that web page. If the connection goes well, an IP address on your network will be presented... briefly.
- Once your esp8266 device is connected to your WiFi, you connect to the ip address of your esp8266 device.
- from there, after searching "Tasmota DHT12" you can configure you esp8266 device to read your temperature sensor.
All that said, I still like an Arduino Nano with the nRF radio (or an RF Nano) and MySensors. I have yet to brick or lose the program of a Nano but have done both on several esp8266's.
OK, back to what I came here to do ... make a serial gateway.