I built a weather station with a mkr1000 and a lipo rider pro powered by a solar panel 3W and a lipo 6ah
It works fine except that when the power go down during the night and go up again when the sun rise the arduino does not reboot and I get no data. If I switch off the arduino and switch on again it works fine. That tells me that there is enough power to restart the arduino but it just does not restart on its own. And obviously I don't want to switch it off/on every morning.
I am pretty sure the solar power won't be able to provide enough power for 7/7 24/24 run of the arduino specially on a cloudy winter day, therefore the problem of the automatic reboot after a power off is a real issue for my project.
The code work very well and I have tested it for days.
The problem is really in the lipo rider pro I think because it does not switch off when the lipo or the solar panel (or both) deliver not enough voltage. In that case I am not sure of the behavior of the mkr1000.
I wonder if there is a device that could protect the power voltage between the mkr1000 and the lipo rider pro. I have read post in forum of people trying to design such a device, I just wish there were one I could buy since I am not good in electronics.
I took a look at the basic specs for the board and it looks very useful although designed for the UNO size boards.
Noticed that it says you can “program” via the USB port.
Do you use that to upload sketches ??
Also how is it connected to the MKR ?? (please include a decent quality picture or a good sketch)
Again… do you have serial output enabled anywhere in your sketch as outlined. ??
Your program may work very well but there are known “restart” issues with the MKR that the JSON seems to have alleviated for me at least.
Also what firmware do you currently have on the MKR ?
Below is the firmware update sketch (also included in WiFi101 examples) and I would suggest you try it and then re-load you sketch and maybe tell us what the original firmware was prior to any update ?
/*
FirmwareUpdate.h - Firmware Updater for WiFi101 / WINC1500.
Copyright (c) 2015 Arduino LLC. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <WiFi101.h>
#include <spi_flash/include/spi_flash.h>
typedef struct __attribute__((__packed__)) {
uint8_t command;
uint32_t address;
uint32_t arg1;
uint16_t payloadLength;
// payloadLenght bytes of data follows...
} UartPacket;
static const int MAX_PAYLOAD_SIZE = 1024;
#define CMD_READ_FLASH 0x01
#define CMD_WRITE_FLASH 0x02
#define CMD_ERASE_FLASH 0x03
#define CMD_MAX_PAYLOAD_SIZE 0x50
#define CMD_HELLO 0x99
void setup() {
Serial.begin(115200);
nm_bsp_init();
if (m2m_wifi_download_mode() != M2M_SUCCESS) {
Serial.println(F("Failed to put the WiFi module in download mode"));
while (true)
;
}
}
void receivePacket(UartPacket *pkt, uint8_t *payload) {
// Read command
uint8_t *p = reinterpret_cast<uint8_t *>(pkt);
uint16_t l = sizeof(UartPacket);
while (l > 0) {
int c = Serial.read();
if (c == -1)
continue;
*p++ = c;
l--;
}
// Convert parameters from network byte order to cpu byte order
pkt->address = fromNetwork32(pkt->address);
pkt->arg1 = fromNetwork32(pkt->arg1);
pkt->payloadLength = fromNetwork16(pkt->payloadLength);
// Read payload
l = pkt->payloadLength;
while (l > 0) {
int c = Serial.read();
if (c == -1)
continue;
*payload++ = c;
l--;
}
}
// Allocated statically so the compiler can tell us
// about the amount of used RAM
static UartPacket pkt;
static uint8_t payload[MAX_PAYLOAD_SIZE];
void loop() {
receivePacket(&pkt, payload);
if (pkt.command == CMD_HELLO) {
if (pkt.address == 0x11223344 && pkt.arg1 == 0x55667788)
Serial.print("v10000");
}
if (pkt.command == CMD_MAX_PAYLOAD_SIZE) {
uint16_t res = toNetwork16(MAX_PAYLOAD_SIZE);
Serial.write(reinterpret_cast<uint8_t *>(&res), sizeof(res));
}
if (pkt.command == CMD_READ_FLASH) {
uint32_t address = pkt.address;
uint32_t len = pkt.arg1;
if (spi_flash_read(payload, address, len) != M2M_SUCCESS) {
Serial.println("ER");
} else {
Serial.write(payload, len);
Serial.print("OK");
}
}
if (pkt.command == CMD_WRITE_FLASH) {
uint32_t address = pkt.address;
uint32_t len = pkt.payloadLength;
if (spi_flash_write(payload, address, len) != M2M_SUCCESS) {
Serial.print("ER");
} else {
Serial.print("OK");
}
}
if (pkt.command == CMD_ERASE_FLASH) {
uint32_t address = pkt.address;
uint32_t len = pkt.arg1;
if (spi_flash_erase(address, len) != M2M_SUCCESS) {
Serial.print("ER");
} else {
Serial.print("OK");
}
}
}
Indeed removing the serail output didn’t change anything
The point is that when the mkr1000 stop sending data I just have to plug it to my laptop usb anf it work fine therefore it is realyy problem of power via the lipo rider pro. Actually it stop twice when the solar panel was under sun light with full power into the lipo battery.
I have no firmwareupdate I use
/libraries/WiFi101-master
and it seems to work pretty well
I don’t understand where I should use a JSON, as you can see in the code i use Thinkspeak to get the data on the web
Here is the code of my weather station
The plugin of the lipo rider pro is pretty simple with the usb conection to the mkr1000 but i will check the conections
You should have the first JSON in there anyway for MKR boards to be able to use the updated packages and board manager. if you don't then I would recommend you do it and double check for any updated packages and libraries too especially the ones for
Arduino SAMD Boards (32-bits ARM Cortex-M0) which should be 1.6.6 hackster.io - MKR1000 which should be 1.6.4-mkr02
Arduino SAMD core - pull request #152 which should be 1.6.6 build 86
If you also use regular Arduinos then the AVR boards might also need an update while you are in there
Current version for that is 1.6.12
When you have done those its worth while also updating the libs
Goto SKETCH
INCLUDE LIBRARY
MANAGE LIBRARIES
Type "mkr" in the search box
click the "more info" for each one listed and update if available.
If it throws you off to a web page then you already have the latest and can close the webpage.