I've made my self a project that monitors how wet the ground in the plants is. Wired it with arduino r4 wifi and everything worked perfectly. made my own pcb for arnuino nano every and i cannot read anything in serial plotter, nothing is shown on printf and project cannot get values from analog pins
#include <SPI.h>
#include "epd1in54_V2.h"
#include "epdpaint.h"
//--- SETUP ---
int refreshDelay = 10;
int analogPins[] = {A0, A1, A2, A3};
//-------------
Epd epd;
unsigned char image[1024];
Paint paint(image, 0, 0);
unsigned long time_start_ms;
unsigned long time_now_s;
#define COLORED 0
#define UNCOLORED 1
// Function declarations
void drawHeader(int number);
void drawBox(int number, double fill);
void setup() {
// Initialize
Serial.begin(9600);
epd.LDirInit();
epd.Clear();
// Draw Headers
for (int i = 1; i <= 4; i++) {
drawHeader(i);
}
// Draw Init Boxes
for (int i = 1; i <= 4; i++) {
drawBox(i, 0);
}
// Show
epd.DisplayFrame();
}
void loop() {
//Get Values and set box sizes
for(int i= 0;i<4;i++){
double value = analogRead(analogPins[i]);
value = value/320;
//Show on serial monitor
Serial.println(value);
printf("%d", value);
drawBox(i+1, value);
}
//Display
epd.DisplayFrame();
delay(1000*refreshDelay);
}
void drawHeader(int number) {
char text[20];
sprintf(text, "%d", number);
paint.SetWidth(40);
paint.SetHeight(20);
paint.Clear(COLORED);
paint.DrawStringAt(14, 5, text, &Font16, UNCOLORED);
epd.SetFrameMemory(paint.GetImage(), (8 + 40) * (number - 1) + 9, 6, paint.GetWidth(), paint.GetHeight());
}
void drawBox(int number, double fill) {
paint.SetWidth(40);
paint.SetHeight(160);
paint.Clear(UNCOLORED);
paint.DrawFilledRectangle(0, paint.GetHeight() * (1 - fill), paint.GetWidth(), paint.GetHeight(), COLORED);
epd.SetFrameMemory(paint.GetImage(), (8 + 40) * (number - 1) + 9, 32, paint.GetWidth(), paint.GetHeight());
}
I have moved your topic from IDE 1.x Category....The Project Guidance Category was more suitable for your question.
Good job for including all the necessary items to help us, help you ....I will leave you to the other members, as it a bit late here.
As far I know, on the Nano Every the Serial, connected to external USB is called Serial1, not a Serial
The onboard serial-to-USB is Serial, the Rx/Tx pins are Serial1, on the Nano Every.
Maybe I forgot something, but it seems to me that on Nano Every 4808 I used Serial1 to output data to PC Serial monotor...
Somehow it started to work with this code
#include <SPI.h>
#include "epd1in54_V2.h"
#include "epdpaint.h"
//--- SETUP ---
int refreshDelay = 1;
int analogPins[] = {A0, A1, A2, A3};
//-------------
Epd epd;
unsigned char image[1024];
Paint paint(image, 0, 0);
unsigned long time_start_ms;
unsigned long time_now_s;
#define COLORED 0
#define UNCOLORED 1
// Function declarations
void drawHeader(int number);
void drawBox(int number, double fill);
void setup() {
// Initialize
Serial.begin(9600);
epd.LDirInit();
epd.Clear();
// Draw Headers
for (int i = 1; i <= 4; i++) {
drawHeader(i);
}
// Draw Init Boxes
for (int i = 1; i <= 4; i++) {
drawBox(i, 0);
}
// Show
epd.DisplayFrame();
}
void loop() {
// Get Values and set box sizes
for (int i = 0; i < 4; i++) {
double value = analogRead(analogPins[i]);
value = value / 700;
// Show on serial monitor
Serial.print(value);
Serial.print(" "); // Add space separator between values
drawBox(i + 1, value);
}
Serial.println(); // Print a new line after all values
// Display
epd.DisplayFrame();
delay(1000 * refreshDelay);
}
void drawHeader(int number) {
char text[20];
sprintf(text, "%d", number);
paint.SetWidth(40);
paint.SetHeight(20);
paint.Clear(COLORED);
paint.DrawStringAt(14, 5, text, &Font16, UNCOLORED);
epd.SetFrameMemory(paint.GetImage(), (8 + 40) * (number - 1) + 9, 6, paint.GetWidth(), paint.GetHeight());
}
void drawBox(int number, double fill) {
paint.SetWidth(40);
paint.SetHeight(160);
paint.Clear(UNCOLORED);
paint.DrawFilledRectangle(0, paint.GetHeight() * (1 - fill), paint.GetWidth(), paint.GetHeight(), COLORED);
epd.SetFrameMemory(paint.GetImage(), (8 + 40) * (number - 1) + 9, 32, paint.GetWidth(), paint.GetHeight());
}
I would wonder if the Nano Every doesn't have enough memory for your arrays plus whatever the epd uses.
Which epd library are you using? There seem to be quite an array of possibilities...
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.