2021-10-03T23:00:00Z
Hi,
wishing everyone good health, in this strange pandemic time......be safe.
I'm having a bit of bother with a project that I want to complete,and I'd really appreciate any advice that might help me achieve the desired outcome.
As part of the project , I'm using a linux OS on a raspberry pi 3 B as my computer and I want to build a DC timer, that can turn on and off a 12volt DC light (on for 5 hours).
Ultimately I want to be able to record the effect a given load has on a 12 volt battery's capacity as part of a micro solar setup. I appreciate there are devices on the market to do this task but I would like to "learn while doing" whenever possible.
My aduino board is a Yun (original) and the RealTimeClock module is a HW-111 12c module.
connections:
RTC_ SCL ....conneced to....Yun_digitalOutput_ 3
RTC_SDA ....connected to...Yun_digitalOutput_ 2
RTC_VCC ....connected to ..Yun_5v
RTC_GND...connected to ..Yun_GND
I found the initial sketch which I thought might work at RandomNerdTutorials .. How to do Daily Tasks with Arduino.
With the Yun connected over USB via /dev/ttyAMAO (Arduino Yun) port the sketch runs just fine
However..... when I tried to run the same sketch over wifi it did not work.
In an attempt to isolate the problem I striped back the project to just The RTC and tried the DS3017RTC . SetTime and ReadTest sketches.
Once again ....over usb the SetTime and ReadTest sketches uploaded and ran perfectly.
This is the ReadTest sketch used:
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
void setup() {
Serial.begin(9600);
while (!Serial) ; // wait for serial
delay(200);
Serial.println("DS1307RTC Read Test");
Serial.println("-------------------");
}
void loop() {
tmElements_t tm;
if (RTC.read(tm)) {
Serial.print("Ok, Time = ");
print2digits(tm.Hour);
Serial.write(':');
print2digits(tm.Minute);
Serial.write(':');
print2digits(tm.Second);
Serial.print(", Date (D/M/Y) = ");
Serial.print(tm.Day);
Serial.write('/');
Serial.print(tm.Month);
Serial.write('/');
Serial.print(tmYearToCalendar(tm.Year));
Serial.println();
} else {
if (RTC.chipPresent()) {
Serial.println("The DS1307 is stopped. Please run the SetTime");
Serial.println("example to initialize the time and begin running.");
Serial.println();
} else {
Serial.println("DS1307 read error! Please check the circuitry.");
Serial.println();
}
delay(9000);
}
delay(1000);
}
void print2digits(int number) {
if (number >= 0 && number < 10) {
Serial.write('0');
}
Serial.print(number);
}
Now I wanted to have the same sketch run over wifi rather than via usb and there seems to be a problem. I have read that if I include "Console.h" and "Bridge.h" and add Console.begin() andBridge.begin() in the void Setup and change all reference to the serial monitor to Console(i.e. Serial.println to Console.println) , then it should fix it ....but unfortunately not!
New Sketch with edits reads
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
#include <Console.h>
#include <Bridge.h>
void setup() {
Console.begin();
Bridge.begin();
while (!Console) ; // wait for serial
delay(200);
Console.println("DS1307RTC Read Test");
Console.println("-------------------");
}
void loop() {
tmElements_t tm;
if (RTC.read(tm)) {
Console.print("Ok, Time = ");
print2digits(tm.Hour);
Console.write(':');
print2digits(tm.Minute);
Console.write(':');
print2digits(tm.Second);
Console.print(", Date (D/M/Y) = ");
Console.print(tm.Day);
Console.write('/');
Console.print(tm.Month);
Console.write('/');
Console.print(tmYearToCalendar(tm.Year));
Console.println();
} else {
if (RTC.chipPresent()) {
Console.println("The DS1307 is stopped. Please run the SetTime");
Console.println("example to initialize the time and begin running.");
Console.println();
} else {
Console.println("DS1307 read error! Please check the circuitry.");
Console.println();
}
delay(9000);
}
delay(1000);
}
void print2digits(int number) {
if (number >= 0 && number < 10) {
Console.write('0');
}
Console.print(number);
}
After uploading sketch, the following error message appears.
Arduino: 1.8.16 (Linux), Board: "Arduino Yún"
Sketch uses 10966 bytes (38%) of program storage space. Maximum is 28672 bytes.
Global variables use 831 bytes (32%) of dynamic memory, leaving 1729 bytes for local variables. Maximum is 2560 bytes.
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e9587
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "0xFF"
avrdude: writing lfuse (1 bytes):
avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xFF:
avrdude: load data lfuse data from input file 0xFF:
avrdude: input file 0xFF contains 1 bytes
avrdude: reading on-chip lfuse data:
avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "0xD8"
avrdude: writing hfuse (1 bytes):
avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xD8:
avrdude: load data hfuse data from input file 0xD8:
avrdude: input file 0xD8 contains 1 bytes
avrdude: reading on-chip hfuse data:
avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xFB"
avrdude: writing efuse (1 bytes):
avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xFB:
avrdude: load data efuse data from input file 0xFB:
avrdude: input file 0xFB contains 1 bytes
avrdude: reading on-chip efuse data:
avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading input file "/tmp/sketch.hex"
avrdude: writing flash (32748 bytes):
avrdude: 32748 bytes of flash written
avrdude: verifying flash memory against /tmp/sketch.hex:
avrdude: load data flash data from input file /tmp/sketch.hex:
avrdude: input file /tmp/sketch.hex contains 32748 bytes
avrdude: reading on-chip flash data:
avrdude: verifying ...
avrdude: 32748 bytes of flash verified
avrdude done. Thank you.
com.jcraft.jsch.JSchException: Session.connect: java.net.SocketException: Broken pipe (Write failed)
at com.jcraft.jsch.Session.connect(Session.java:557)
at processing.app.NetworkMonitor.open(NetworkMonitor.java:73)
at processing.app.AbstractMonitor.resume(AbstractMonitor.java:132)
at processing.app.Editor.resumeOrCloseSerialMonitor(Editor.java:2131)
at processing.app.Editor.access$1300(Editor.java:116)
at processing.app.Editor$UploadHandler.run(Editor.java:2095)
at java.lang.Thread.run(Thread.java:748)
Session.connect: java.net.SocketException: Broken pipe (Write failed)
com.jcraft.jsch.JSchException: session is down
at com.jcraft.jsch.Channel.sendChannelOpen(Channel.java:667)
at com.jcraft.jsch.Channel.connect(Channel.java:151)
at com.jcraft.jsch.Channel.connect(Channel.java:145)
at processing.app.NetworkMonitor.tryConnect(NetworkMonitor.java:98)
at processing.app.NetworkMonitor.access$100(NetworkMonitor.java:25)
at processing.app.NetworkMonitor$3.run(NetworkMonitor.java:139)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
And finally the serial monitor/console reads
Unable to connect: retrying (0)...
I would really appreciate any help at all in helping to get to the bottom of this problem.
Thanking you