How to fix this problem? I've searched and found nothing about library for Software.Serial.h
Your topic has been moved to the Programming category
Which Arduino board are you using ?
Please post your sketch, using code tags when you do
Really ?
Sounds incredible.
Is Google not accessible to you?
To fix this error, you need to download and install SoftwareSerial library.
This tutorial will help you
Did you try SoftwareSerial.h, without the dot in the middle?
Judging by the error message the sketch does not have the full stop in the name
My bet is that @dfarkann is using a board that does not support (or need) SoftwareSerial but until we have more details, who knows ?
The error message clearly indicates that the library is not installed at all. Is it compatible with the OP's project - this is the second question
I'm currently using a MKR WiFi 1010 board
here is the code
#include <SoftwareSerial.h>
#define RE 8
#define DE 7
//const byte code[]= {0x01, 0x03, 0x00, 0x1e, 0x00, 0x03, 0x65, 0xCD};
const byte nitro[] = {0x01,0x03, 0x00, 0x1e, 0x00, 0x01, 0xe4, 0x0c};
const byte phos[] = {0x01,0x03, 0x00, 0x1f, 0x00, 0x01, 0xb5, 0xcc};
const byte pota[] = {0x01,0x03, 0x00, 0x20, 0x00, 0x01, 0x85, 0xc0};
byte values[11];
SoftwareSerial mod(2,3);
void setup() {
Serial.begin(9600);
mod.begin(9600);
pinMode(RE, OUTPUT);
pinMode(DE, OUTPUT);
//delay(3000);
}
void loop() {
byte val1,val2,val3;
val1 = nitrogen();
delay(250);
val2 = phosphorous();
delay(250);
val3 = potassium();
delay(250);
Serial.print("Nitrogen: ");
Serial.print(val1);
Serial.println(" mg/kg");
Serial.print("Phosphorous: ");
Serial.print(val2);
Serial.println(" mg/kg");
Serial.print("Potassium: ");
Serial.print(val3);
Serial.println(" mg/kg");
delay(2000);
}
byte nitrogen(){
digitalWrite(DE,HIGH);
digitalWrite(RE,HIGH);
delay(10);
if(mod.write(nitro,sizeof(nitro))==8){
digitalWrite(DE,LOW);
digitalWrite(RE,LOW);
for(byte i=0;i<7;i++){
//Serial.print(mod.read(),HEX);
values[i] = mod.read();
Serial.print(values[i],HEX);
}
Serial.println();
}
return values[4];
}
byte phosphorous(){
digitalWrite(DE,HIGH);
digitalWrite(RE,HIGH);
delay(10);
if(mod.write(phos,sizeof(phos))==8){
digitalWrite(DE,LOW);
digitalWrite(RE,LOW);
for(byte i=0;i<7;i++){
//Serial.print(mod.read(),HEX);
values[i] = mod.read();
Serial.print(values[i],HEX);
}
Serial.println();
}
return values[4];
}
byte potassium(){
digitalWrite(DE,HIGH);
digitalWrite(RE,HIGH);
delay(10);
if(mod.write(pota,sizeof(pota))==8){
digitalWrite(DE,LOW);
digitalWrite(RE,LOW);
for(byte i=0;i<7;i++){
//Serial.print(mod.read(),HEX);
values[i] = mod.read();
Serial.print(values[i],HEX);
}
Serial.println();
}
return values[4];
}
sorry, that's a typo
Why do you need to use SoftwareSerial when the board has a serial port (named Serial1) on pin 14 (TX, output) and pin 13 (RX, input) ?
Use Serial1 instead of SoftwareSerial. E.g. replace mod.begin(9600)
by Serial1.begin(9600)
; pins are 13 and 14 (see the pinout). Repeat for all other usage of mod
.
pardon me, because I'm just learning about this
thank you for ur advice
Yep those things can cause a lot of damage when they come ashore, like the one in California last week.
The error message clearly indicates that the library is not installed at all.
Due to the architecture-specific nature of its implementation, "SoftwareSerial" is a "platform bundled" library.
The libraries that are installed under the sketchbook via Library Manager, "Add .ZIP Library", or manually are always accessible but the libraries bundled with a platform are only accessible when compiling for a board of that platform. For example, if you compile a sketch with a SoftwareSerial.h
#include
directive with a board of the "Arduino AVR Boards" platform (which does contain a bundled "SoftwareSerial" library) selected in the Arduino IDE Tools > Board menu, you will not encounter a "SoftwareSerial.h: No such file or directory
" error. But if you then change the Board menu selection to a board of the "Arduino SAMD Boards (32-bits ARM Cortex-M0+)" platform (which does not contain a bundled "SoftwareSerial" library) and compile the same sketch again, you will get the "SoftwareSerial.h: No such file or directory
" error even though there is an installation of the "SoftwareSerial" library under the "Arduino AVR Boards" platform.
Thank you
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.