Does ATtiny85 microcontroller support AT-commands?

Can ATtiny microcontroller send at commands to sim800l or sim800h gsm module? What is smallest microcontroller that can do this? (Rx , tx and rst pins are maybe required and at command support of course.
Also it d be good if it could be programmed from arduino uno.

Sim800l ---->

https://www.google.fi/imgres?imgurl=http%3A%2F%2Fi.lnwfile.com%2F_%2Fi%2F_raw%2Fsm%2Fut%2Fmd.jpg&imgrefurl=https%3A%2F%2Fforum.arduino.cc%2Findex.php%3Ftopic%3D337710.0&docid=jI2REnFC1C-58M&tbnid=FhzREnOPcG7F7M%3A&w=641&h=402&client=ms-android-huawei&bih=511&biw=360&ved=0ahUKEwi3jLq7i5vPAhXBF5oKHfVhBiUQMwgdKAQwBA&iact=mrc&uact=8

By AT commands you mean serial communication. ATtiny85 doesn't have hardware serial but supposedly there are some software serial implementations for ATtiny85 available. Software serial doesn't support as high of baud rates as hardware serial does. The ATtiny85 is limited on memory and pins so you are going to have trouble doing much else with it. So I guess that pretty much answers your question of the smallest microcontroller that can do it. You'd probably be better off just using an ATmega328P but sometimes it's fun to use the minimum possible microcontroller that can meet your needs, though it can be limiting if you want to add features later.

Computerguy123:
Also it d be good if it could be programmed from arduino uno.

I'm guessing by that you mean using an Uno for Arduino as ISP programmer to program the ATtiny85. If so, yes you can definitely do that.

Ok. I planned to use this code. Does this include some commands that those attiny85 doesnt support? Will it work in that microcontroller?

#include
SoftwareSerial sim800(8,9);

char phone_number1[]=”+xxxxxx”; // put phone number here, international format, no spaces
char phone_number2[]=”+xxxxxx”;
unsigned long time_pressed4;
unsigned long time_pressed5;
boolean SIMok = false;
int current_status;

void setup() {
delay(5000);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);

pinMode(11, OUTPUT); // green LED
pinMode(12, OUTPUT); // red LED
digitalWrite(11, HIGH); // blink green and red LED
digitalWrite(12, HIGH);
delay(500);
digitalWrite(11, LOW);
digitalWrite(12, LOW);

pinMode(7, OUTPUT); // sim800 RESET
digitalWrite(7, LOW);

Serial.begin(9600);
sim800.begin(9600);

Serial.print(F(“Testing sim800 module.. “));
SIMok = false;
for (int i=0;i<3;i++) {
if (simReady()) {
SIMok = true;
break;
}
}

if (SIMok) simDetails(); // get some details on SIM
else { // if SIM not OK then blink RED forever
for (;:wink: {
digitalWrite(12, HIGH);
delay(100);
digitalWrite(12, LOW);
delay(100);
}
}
digitalWrite(11, HIGH); // green LED on for SIM ok
}

void loop() {

current_status = checkStatus();
// Serial.println(current_status); // 48: ready 51: ringing 52: in call

if (current_status == 52) { // IN CALL (should be 4 according to datasheet)
Serial.println("52: in call");
digitalWrite(12, HIGH); // red LED on when in call
delay(500);
if (!digitalRead(4) || !digitalRead(5)) { // if push any button hang up call
digitalWrite(12, LOW); // red LED off after hang up
sim800.println("ATH");
Serial.println(F("Hanging up call"));
simReply();
}
}
else {
if (current_status == 51) { // RINGING (should be 3 according to datasheet)
Serial.println(F("51: incoming call.."));
digitalWrite(12, HIGH); // blink red LED when ringing
delay(500);
digitalWrite(12, LOW);
if (!digitalRead(4)|| !digitalRead(5)) { // if push any button answer call
digitalWrite(12, HIGH); // red LED on when in call
sim800.println("ATA");
Serial.println(F("Answering call"));
simReply();
}
}
else {
digitalWrite(12, LOW);
if (digitalRead(4)) time_pressed4 = millis(); // button not pushed
else if (millis() - time_pressed4 > 500) simCall(phone_number1); // button pushed, call if long push

if (digitalRead(5)) time_pressed5 = millis(); // button not pushed
else if (millis() – time_pressed5 > 500) simCall(phone_number2); // button pushed, call if long push
}
}
}

boolean simReady() { // SIM READY

digitalWrite(7, LOW); // hardware reset after sleep RST
delay(1000);
digitalWrite(7, HIGH);

// time to startup 3 sec
for (int i=0;i<6;i++) {
digitalWrite(11, HIGH); // green LED blink
delay(250);
digitalWrite(11, LOW);
delay(250);
}

sim800.println("AT");
delay(100);
if (sim800.find("OK")) {
Serial.println(F("OK"));
Serial.print(F("Registering on the network.."));
for (int i = 0; i<20; i++) {
// time to register on network 2.5 sec
for (int i=0;i<5;i++) {
digitalWrite(11, HIGH); // green LED blink
delay(250);
digitalWrite(11, LOW);
delay(250);
}
Serial.print(".");
sim800.println("AT+CREG?"); // possible replies: 0,0=not registered 0,1=registered on home network 0,2=not registered but searching 0,3=denied 0,4=unknown 0,5=roaming
delay(1000);
if (sim800.find("0,1")) {
Serial.println(F(" OK"));
return true;
}
}
Serial.println(F("failed to register for 1min, will reset sim800"));
return false;
}
else
{
Serial.println(F("sim800 module not OK, please check"));
return false;
}
}

void simReply() { // SIM REPLY
delay(500);
while (sim800.available()) {
char c = sim800.read();
// if (c != '\n') Serial.write(c); // replace new line with space
// else Serial.print(" ");
delay(5);
}
// Serial.println();
}

int checkStatus() { // CHECK STATUS FOR RINGING or IN CALL

sim800.println("AT+CPAS"); // phone activity status: 0= ready, 2= unknown, 3= ringing, 4= in call
delay(500);
if (sim800.find("+CPAS: ")) { // decode reply
char c = sim800.read();
simReply();
return c;
}
else return -1;
}

void simCall(char number[]) {

digitalWrite(12, HIGH);
Serial.print("Start call.. ");

sim800.println("AT+CREG?"); // possible replies: 0,0=not registered 0,1=registered on home network 0,2=not registered but searching 0,3=denied 0,4=unknown 0,5=roaming
delay(1000);
if (sim800.find("0,1")) {
Serial.println(F("network connection still OK"));
simReply();
}
else {
SIMok = false;
for (int i=0;i<3;i++) {
if (simReady()) {
SIMok = true;
break;
}
}
if (!SIMok) { // SIM not ok, blink RED forever
for (;:wink: {
digitalWrite(12, HIGH);
delay(100);
digitalWrite(12, LOW);
delay(100);
}
}
}

Serial.print("Calling number ");
Serial.println(number);
String cmd; // make call command
cmd = "ATD";
cmd += number;
cmd += ";";
sim800.println(cmd);
delay(1000);
simReply();
}

void simDetails() {
Serial.print(F("operator:"));
sim800.println("AT+COPS?"); // OPERATOR
delay(500);
if (sim800.find(":")) { // decode reply
while (sim800.available()) {
char c = sim800.read();
if (c != '\n') Serial.write(c); // replace new line with space
else Serial.print(" ");
delay(5);
}
}
else Serial.print(F("n/a"));
Serial.println();

Serial.print(F("signal strength:"));
sim800.println("AT+CSQ"); // SIGNAL STRENGTH
delay(500);
if (sim800.find(":")) { // decode reply
while (sim800.available()) {
char c = sim800.read();
if (c != '\n') Serial.write(c); // replace new line with space
else Serial.print(" ");
}
}
else Serial.print(F("n/a"));
Serial.println();

Serial.print(F("battery level:"));
sim800.println("AT+CBC"); // BATTERY LEVEL
delay(500);
if (sim800.find(":")) { // decode reply
while (sim800.available()) {
char c = sim800.read();
if (c != '\n') Serial.write(c); // replace new line with space
else Serial.print(" ");
}
}
else Serial.print(F("n/a"));
Serial.println();

sim800.println("AT+CLVL=80"); // set speaker volume 0-100
simReply();
sim800.println("AT+CRSL=80"); // set ringer volume 0-100
simReply();
sim800.println("AT+CMIC=0,12"); // set mic to gain level 0-15
simReply();
// ring tone AT+CALS=5,1 to switch on tone 5, 5,0 to switch off
sim800.println("AT+CALS=19"); // set alert/ring tone
simReply();

Serial.println("Ready");
}

Computerguy123:
Does this include some commands that those attiny85 doesnt support?

Computerguy123:
for (;:wink:

Yes, ATtiny85 definitely doesn't support smiley faces.

Please always use code tags(</> button on the toolbar) when you post code or error/warning messages on the forum. This will ensure that your code isn't interpreted by the forum as markup. This is one of the forum rules, which you would know if you had read How to use this forum - please read.. Please also use Tools > Auto Format on your code always before posting it.

It looks like ATTinyCore includes a SoftwareSerial library: ATTinyCore/avr/libraries/SoftwareSerial at OldMaster---DO-NOT-SUBMIT-PRs-here-Use-2.0.0-dev · SpenceKonde/ATTinyCore · GitHub.

The Serial.print() commands won't work. Those are for hardware serial, which the ATtiny85 doesn't have. I'm not sure if you will be able to run two different software serial channels on the ATtiny85. Obviously you won't be able to use pin 12 for digitalWrite() because the ATtiny85 doesn't have 12 pins but you would just need to change the pin number.

The ATtiny85 only has 5 pins to use as digital and/or analogue pins (only 8 pins in total, including Vcc, GND, reset).
So commands like

pinMode(11, OUTPUT); // green LED

or

SoftwareSerial sim800(8,9);

will not work,
because you try to use pins that does not exist on this small chip.

So the code has to be modified.

If you want to have a smaller device (smaller in the sens of using less space): have you thought about using one of the smaller Arduino boards like Micro, Mini or Nano?

Use code tags. ATTiny85 needs to use software serial, so the commands are different.
Whatever library you're using, you may need to redefine timers.

If you try to use two software serial instances at the same time you're almost surely going to end up in a bad place - if either one of them attempts to send while it or the other one is receiving, the send and receive will be garbage. So the only way to have multiple software serial ports, and not have them fight eachother, is to turn off one of them when you think the other might be receiving stuff, and vise versa, which is really awkward.

While some cores (including mine) do provide a "Serial" object, this is just another software serial instance (in my core, it's implemented with fixed pins to use the analog comparator interrupt, preventing conflict with libraries that use PCINTs). That does not change the issue noted above.

So yeah - you need to get rid of all the use of Serial and fix the pin numbers.

My impression of your sketch though is that it's whole reason for existance requires the serial port talking to the computer, meaning you need two serial ports, and as noted above, this is a problem, since you only get one software serial without jumping through hoops, and the '85 doesn't have a hardware serial port.

I also suspect flash space will be an issue.

Some alternatives:

The ATtiny841 (pin compatible with the '84, though available in SMD packages only) has TWO hardware serial ports, as well as boatloads of other features (including two 16-bit timers, plus the usual 8bit one, for 6 PWM pins). Also has an insanely feature-heavy ADC, if you're into that. The SMD only packages make it a bit harder to get started. 8k flash 512 ram, like the 85. Costs only a couple cents more than an '84.

The ATTiny1634 also has two hardware serial ports, and more ram/flash, which I suspect you'll be short on with an 8k chip. It's a little less interesting in terms of the other peripherals though - just a USI and the usual 8 and 16-bit timer 0 and 1)

The ATtiny167 is also an option - it has one hardware serial - but it's a little pricey, and the rest of it's feature set isn't very interesting for most hobbyists.

Another approach is to just use an ATMega328p - pro mini clones are insanely cheap, and it's tough to justify using attinies for small or one-off projects.

Support for the attiny chips can be achieved with my core: GitHub - SpenceKonde/ATTinyCore: Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8

Since the 841 and 1634 are SMD only, which makes prototyping difficult for many hobbyists I happen to sell breakout boards for them, assembled or non, from my Tindie Store

Sorry sorry. Will those scetch work in arduino mini clone when i change pin numbers to correct?

Clone:

Atmega168 Module
Condition: new
14 digital input/output port RX, TX, D2 ~ D13
8 analog input port A0 ~ A7
1 to TTL level port RX/TX
6 PWM port, D3, D5, D6, D9, D10, D11
Using Atmel Atmega328P - AU microcontroller
Support serial download
Support external 3.3 V ~ 12 V dc power supply
Support 9v battery power supply
Clock frequency 8 MHZ
Size: 33.3 * 18 mm
Color: as pictures
Attention: PLS NOTE that due to lighting effects, monitor's brightness / contrast settings etc, there could be some slight differences in the color tone of the pictures and the actual item!
Package includes:

1PCS Pro Mini atmega168 3.3V 8M Arduino Compatible Nano replace Atmega328

Yes

Uno/Mini/Nano/Pro Mini all use the same chip and have the same pin mapping, so if you're coming from one of those, you don't even have to change pin numbers. (That board sounds like a pro mini to me)

One wonders if the board actually has a '328, '328p, or '168 on it - they say both at varying times. Though '168-based pro mini is supported by the IDE, so they'll all work. (difference between 168 and 328 is the flash and ram size)

I'd assume ATmega168. I like how they say "replace Atmega328" like it's some kind of an upgrade. I compiled the provided code for ATmega168 and it will fit with room to spare but since there's usually almost no price difference between ATmega168 and ATmega328P based Pro Mini clones I'd get the ATmega328P instead to have some room to grow.

pert:
I'd assume ATmega168. I like how they say "replace Atmega328" like it's some kind of an upgrade. I compiled the provided code for ATmega168 and it will fit with room to spare but since there's usually almost no price difference between ATmega168 and ATmega328P based Pro Mini clones I'd get the ATmega328P instead to have some room to grow.

AFAIK the pro mini clones with 168's run at 3.3V, which is part of their appeal.

You can get 3.3V Pro Minis with ATmega328 also. For example this one: www.ebay.com/itm/282177459450, which is the same price as the cheapest ATmega168, $1.87 USD. You can probably get them even cheaper on Aliexpress but the shipping and customer service seem to not be so good as on eBay.

EDIT: Yes, here for $1.74USD: https://www.aliexpress.com/item/1pcs-ATMEGA328P-Pro-Mini-328-Mini-ATMEGA328-3-3V-8MHz-for-Arduino-module/32471148123.html but for such a small difference I'd go with the eBay item unless you're buying a bunch of them. The ATmega168 version is $1.61: https://www.aliexpress.com/item/Pro-Mini-atmega168-3-3V-8M-Compatible-Nano-replace-Atmega328/32502123540.html.