×

INDI Library v1.9.2 Released (14 Sep 2021)

Bimonthly Stable INDI Library release introduces new drivers and fixes for existing ones.

Weather radio don't want connect

  • Posts: 89
  • Thank you received: 16
Slight progress

There is a clue to setting the Static JsonDocument in the webpages

arduinojson.org/v6/assistant/

I set mine to 194 to allow for the JSON data and the strings
How to work this out on the fly for different sensor and outputs?

The main problem with the outputting is with serializeJsonPretty, this puts out a very long output with all those nice spaces and ^M at the end.
This seems to overrun the memory which is put into String result="";
I am not sure how the String object looks after its memory, or if you have to reserve memory for it yourself, and free it up afterwards etc.

You can specify how much to output in the serialze functions

I tried to output to a buffer and set a size limit on this
#include <ArduinoJson.h>
#define DESTBUFSIZE 320
char destBuf[DESTBUFSIZE];
 
#ifdef __arm__
// should use uinstd.h to define sbrk but Due causes a conflict
extern "C" char* sbrk(int incr);
#else  // __ARM__
extern char *__brkval;
#endif  // __arm__
 
int freeMemory() {
  char top;
#ifdef __arm__
  return &top - reinterpret_cast<char*>(sbrk(0));
#elif defined(CORE_TEENSY) || (ARDUINO > 103 && ARDUINO != 151)
  return &top - __brkval;
#else  // __arm__
  return __brkval ? &top - __brkval : &top - __malloc_heap_start;
#endif  // __arm__
}
 

In the getSensorData I changed it to use the buffer and permitted length.
void getSensorData(bool pretty) {
 
and
 
  int ret;
 
  destBuf[0] = 0;// Null terminator
 
  if (pretty)
    ret = serializeJsonPretty(weatherDoc, destBuf, DESTBUFSIZE);
  else
    ret = serializeJson(weatherDoc, destBuf, DESTBUFSIZE);
 
  Serial.print("ret :"); Serial.println(ret);
  Serial.print("Free Memory: "); Serial.println(freeMemory());
  Serial.print("DestBuf :"); Serial.println(destBuf);

Then in the w and p commands
    case 'w':
      //Serial.println(getSensorData(false));
      getSensorData(false);
      Serial.println(destBuf);
      break;
    case 'c':
      Serial.println(getCurrentConfig());
      break;
    case 'p':
      //Serial.println(getSensorData(true));
      getSensorData(true);
      Serial.println(destBuf);
      break;

Not sure if this is the best approach. I do remember trying to understand the firmata stuff on the old meteostation and wringing my hands.
9 months 2 weeks ago #65715

Please Log in or Create an account to join the conversation.

  • Posts: 89
  • Thank you received: 16
Of course the Wemos D1 mini (4Mb) pro (16Mb) is flush with memory compared to the Uno (32K flash and 2K SRAM)

So if a Wemos D1 mini pro is used there will be no shortage of ram compared to the UNO.
9 months 1 week ago #65753

Please Log in or Create an account to join the conversation.

  • Posts: 858
  • Thank you received: 258
Adrian,
I filled a breadboard with a BME280, a DHT11, a MLX90614, a TSL2591, a RG-11, a Davis Wind sensor and a OLE display. At least on a Wemos D1 mini, serializing works fine:
{
 
  "Davis Anemometer": {
    "init": true,
    "direction": 3,
    "avg speed": 0,
    "min speed": 0,
    "max speed": 0,
    "rotations": 0
  },
 
  "Rain Sensor": {
    "init": true,
    "rainfall": 0,
    "count": 0
  },
 
  "BME280": {
    "init": true,
    "Temp": 21.08,
    "Pres": 974.0237,
    "Hum": 26.83203
  },
 
  "DHT": {
    "init": true,
    "Temp": 19.9,
    "Hum": 36
  },
 
  "MLX90614": {
    "init": true,
    "T amb": 21.01,
    "T obj": 20.55001
  },
 
  "TSL2591": {
    "init": true,
    "Lux": 1.487565,
    "Visible": 505,
    "IR": 108,
    "Gain": 32,
    "Timing": 1
  }
}

Therefore I suspect it is a memory issue or a cabling problem.

Wolfgang
TSA-120 + FSQ-85 + GSO 150/750 | Avalon Linear + M-zero | ASI 1600mm pro + 6200mm pro | KStars/INDI on Raspberry Pi 4/Intel NUC
9 months 1 week ago #65806

Please Log in or Create an account to join the conversation.

  • Posts: 89
  • Thank you received: 16
Thanks for looking at that Wolfgang, you are very kind to do all that work.

Do you have an Uno to try with?

Like Mark I doubted my wiring so I had redone it several times before I looked at the code.

Yes, it definitely seems to be due to lack of memory on the UNO.

Options:
- Use bigger memory device, like your Wemos D1
- Limit sensors used
- Spread sensors over several microcontroller boards
- It may be possible to save some memory, so that lower powered devices can be used

The main memory hogs are the JSON calls that are copied back to a large long string. The JSON object is big and the string output to the serial port is larger.
In addition, reading about the String object suggests that it is somewhat notorious for giving memory problems.

I have been looking at the code and I am trying to get rid of the String objects and the ArduinoJSON library.

I see the same information is in three places - the basic structure storing the results for each sensor, the JSON object
and the large character buffer that is built up to send to the serial port.

I have written a shortJSON library to generate the JSON strings. I store these in a character buffer for each sensor (the memory is assigned at the start and continuously reused) I just allocated a little more characters than are needed to accomodate the sensor readings.
At the moment I call the function to update this character buffer every time
when the sensor is updated (I call it after the structure is updated eg mlxData.variable.= mlxreadCAll(object).
This is a little wasteful in processing time but the strings are just there and ready to go when they are requested.

These are just Serial.print(MLXstring); on the calls to w, p etc. from the serial console.

I have these working for davis, mlx, tsl and bme, no problem with funny output or memory shortage so far, so seems stable with less memory usage.

Before I move on to the other sensors I will see if I can get indi to talk to the new code.

I will upload the code to github so you can have a look at it.

Kind regards,

Adrian
9 months 1 week ago #65811

Please Log in or Create an account to join the conversation.

  • Posts: 858
  • Thank you received: 258
Is there a specific reason why you are using an Uno instead of a ESP8266 type Arduino? A Wemos D1 mini looks like significantly more powerful, has WiFi inside, is quite small and costs only a few Euros...
TSA-120 + FSQ-85 + GSO 150/750 | Avalon Linear + M-zero | ASI 1600mm pro + 6200mm pro | KStars/INDI on Raspberry Pi 4/Intel NUC
9 months 1 week ago #65859

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 2
Personally, I have lots of unos and xbees lying around so I'm just trying to use them rather than buying new kit. There's something nice too about using minimal kit - the easy option for these kind of projects is always to use another raspberry pi and wireless - the cost isn't too much, but where's the fun in that? :)
9 months 1 week ago #65860

Please Log in or Create an account to join the conversation.

  • Posts: 89
  • Thank you received: 16
I have unos and nanos and no Wemos D1, probably should invest I suppose.

I have been using the usb cable to power the microcontroller and communicate with it (two objectives with one cable).

I bought a longer USB cable which goes to the weather station's microcontroller.
This is commected back to a raspberry pi in a nicer weather proof environment which has AC power and an ethernet connection.

The wifi from the house does not reach the garden well where the pi is and is much less reliable than the cable usually.

I did set up the pi as a wifi hotspot so that the pi zero on the skycam can communicate back, so it would be easy to use this trick with a Wemos.

Still have to get power to the pizero and have used a portable power bank 5V (lasts the whole night) and 12V DC via buck converter to 5 V,
which I can power via a 12V battery or a 12V power supply running off the mains. Suppose I could power the Wemos in a similar fashion.

Bit old fashioned with the uno, I know. Suppose I should move with the times!
9 months 1 week ago #65862

Please Log in or Create an account to join the conversation.

  • Posts: 89
  • Thank you received: 16
My investment has arrived a nice little Wemos No NAME D1 mini EUR 5.59, for pennies.
SSD1306 OLED 0.96", EUR 6.46.

I also discovered that you can use a slightly different oled begin call to use my old SH1106, but there are some artefacts.

Works perfectly with version 1.11 development with my hardware, (MLX90614, BME280, TSL2591, Davis anenometer, OLED)
Had to figure out that the pins have a different numbering to the arduino.
Wemos	Arduino	Connected
D0	16
D1	5	Yellow	SCL
D2	4	Green	SDA
D3	0	Purple	Anenometer Wind Speed
D4	2	
D5	14
D6	12
D7	13
D8	15	Grey	Button
Tx	1
Rx	3

So this confirms problem on older hardware is not a wireing problem but most likely a short of memory problem,
I will let it run for a few days to see if there are any crashes or bugs, that I can see.

Then I will try with the RG-11.

As promised I have developed a slim version for the arduino UNO, which is free for perusal on github, the code is very simple
but will work with the sensors above (didn't try OLED) and not crash the arduino.

Feel free to look at it if you wish
github.com/procras2/OledBME

I got it to talk with indi after I figured out the firmware version number must be surrounded by ".

Now that I see how nice the wemos is, I will try to build my next station (no leaks!) with it.

Adrian
Last edit: 9 months 1 week ago by Adrian. Reason: Forgot url
9 months 1 week ago #66072

Please Log in or Create an account to join the conversation.

  • Posts: 195
  • Thank you received: 3
Hello
I still have my recurring problem that causes the station to make a mistake every 1 to 2 weeks.
******************************************************************************************************
afa@NAFABox:~$ sudo service indi-weatherradio status
[sudo] Mot de passe de nafa :
● indi-weatherradio.service - INDI server for weather radio
Loaded: loaded (/etc/systemd/system/indi-weatherradio.service; enabled; vendo
Active: failed (Result: exit-code) since Fri 2021-01-15 01:19:02 CET; 3 days
Process: 1270 ExecStart=/usr/bin/indiserver -v indi_weatherradio (code=exited,
Main PID: 1270 (code=exited, status=1/FAILURE)

Warning: Journal has been rotated since unit was started. Log output is incomple
lines 1-7/7 (END)
***********************************************************************************************
do you have an idea where the problem can come from?
Can an update fix the problem?

And above all, how to update without changing the different settings made from the beginning.
I ask because it's not me who installed it and I'm still a novice in linux.

Best regards
Christophe
9 months 6 days ago #66097

Please Log in or Create an account to join the conversation.

  • Posts: 858
  • Thank you received: 258
Salut Christophe,
it looks like starting the indiserver fails or it fails with an exception during runtime. Have you tried to start it manually? Execute the following from a terminal and post here what happens:
/usr/bin/indiserver -v indi_weatherradio

Regarding the configurations: there are several configurations:
  • For the Arduino firmware, config.h holds the configuration of the firmware loaded onto the Arduino.
  • The INDI service stores the service configuration in .indi/Weather Radio_config.xml
  • For the web page scripts, wr_config.py holds the configuration for updating the web page data
HTH
Wolfgang
TSA-120 + FSQ-85 + GSO 150/750 | Avalon Linear + M-zero | ASI 1600mm pro + 6200mm pro | KStars/INDI on Raspberry Pi 4/Intel NUC
9 months 6 days ago #66117

Please Log in or Create an account to join the conversation.

  • Posts: 195
  • Thank you received: 3
so here's what it looks like with the command line

nafa@NAFABox:~$ /usr/bin/indiserver -v indi_weatherradio
2021-01-18T22:28:22: startup: /usr/bin/indiserver -v indi_weatherradio
2021-01-18T22:28:22: Driver indi_weatherradio: pid=3666 rfd=3 wfd=6 efd=7
2021-01-18T22:28:22: listening to port 7624 on fd 4
2021-01-18T22:28:22: Driver indi_weatherradio: snooping on GPS Simulator.GEOGRAPHIC_COORD

does it help you understand my problem?

and I always launch it manually, the program and on a dedicated arduino only for the weather.

I think it lasts about 7 days. Is there a way to make it reboot automatically every hour at a certain time?


PS: And something out of the question, since you're so good, would it be possible to get a statistic of the nights?
so that we can know which nights were good during the year.
9 months 6 days ago #66141

Please Log in or Create an account to join the conversation.

  • Posts: 858
  • Thank you received: 258
Not yet, since this only shows that it is working. You should log the output so that we can find the problem.
/usr/bin/indiserver -v indi_weatherradio >> /tmp/indiserver.log
I wouldn‘t recommend it, better track down the problem. I have it running for months without a problem.

I‘m not so sure what you mean. Is this more than the recording done for the weather radio web page? Take a look at my own instance here: weather.openfuture.de/
TSA-120 + FSQ-85 + GSO 150/750 | Avalon Linear + M-zero | ASI 1600mm pro + 6200mm pro | KStars/INDI on Raspberry Pi 4/Intel NUC
9 months 6 days ago #66144

Please Log in or Create an account to join the conversation.

Time to create page: 1.047 seconds