I am trying to send data to my attiny via UART. Not sure if I am missing something. I am using the PB1(MISO) and PB0 (MOSI) pins but no luck. I've tried the CP2102 with arduino and it works well, but having some issues with attiny.
Reason I need to send data is because it uses a command to start the monitor, and I can't start it unless I am able to send a "!" to it.
edit: just to be clear I can read the serial data from arduino (using knockbang), its getting it to send the '!" command to initialize reading from the CP2102 that is giving me issues.
hiduino:
Do you have sample code of what you are trying?
And any schematics or pictures?
#define KNOCK_BANG 1
#include <TinyDebugKnockBang.h>
#ifdef KNOCK_BANG
#define Serial Debug
#endif
void setup() {
Serial.begin( 9600 );
}
void loop() {
delay(1000);
Serial.println("Can it be true?! An attiny serial monitor indeed!"); // debug output
}
thats the sketch. and as for how I am connecting it is simply gnd to gnd 3.3v to vcc on attiny and then that MISO and MOSI connections on the attiny from the uart bridge, its really simple connection. I can get it to work with arduino but not this core because I need to be able to send that "!" to initiate the serial monitor.
Don't use Knock_Bang. Use the software serial that should be part of Tiny-core.
/*
TinySerial
Echo back Serial data.
*/
#include <SoftwareSerial.h>
// Setup serial Rx to pin PB0(D0) and Tx to pin PB1(D1)
SoftwareSerial mySerial(0,1);
int data = 0;
void setup() {
mySerial.begin(9600);
}
void loop() {
if (mySerial.available()) {
data = mySerial.read();
mySerial.write(data);
}
}
Note: There are some limitations with software serial Rx receiving. Although you can use 9600 baud, it won't support back-to-back characters. So as long as you send each data character spaced out with some delay between them then you should be fine. Also for 9600 baud you need to be running at least the 8MHz internal clocking on the ATtiny.
hiduino:
Don't use Knock_Bang. Use the software serial that should be part of Tiny-core.
/*
TinySerial
Echo back Serial data.
*/
#include <SoftwareSerial.h>
// Setup serial Rx to pin PB0(D0) and Tx to pin PB1(D1)
SoftwareSerial mySerial(0,1);
int data = 0;
void setup() {
mySerial.begin(9600);
}
void loop() {
if (mySerial.available()) {
data = mySerial.read();
mySerial.write(data);
}
}
Note: There are some limitations with software serial Rx receiving. Although you can use 9600 baud, it won't support back-to-back characters. So as long as you send each data character spaced out with some delay between them then you should be fine. Also for 9600 baud you need to be running at least the 8MHz internal clocking on the ATtiny.
I can get my example to work, but yours seems to not work
actually code on this page seemed to work. SGMKtiny - SGMK-SSAM-WIKI only difference is the baud rate, no idea why it work work and not yours otherwise