Skip to content

Instantly share code, notes, and snippets.

@Girgitt
Created November 14, 2017 10:27
Show Gist options
  • Save Girgitt/81de1e290fae0b6bd9b8c4f5d5991aec to your computer and use it in GitHub Desktop.
Save Girgitt/81de1e290fae0b6bd9b8c4f5d5991aec to your computer and use it in GitHub Desktop.
Adruino string and value concat
float v_s_r = analogRead(SUPP_VOLTAGE_PIN);
float supp_voltage = (5.0 / 1024) * v_s_r * 3.0;
String v_s = "supp_v:";
v_s.concat(supp_voltage);
int v_s_str_len = v_s.length() + 1; //we need extra space for the null terminator thus len += 1
char v_s_send[v_s_str_len];
v_s.toCharArray(v_s_send, v_s_str_len);
bus.send(200, v_s_send, v_s_str_len - 1); // we don't want to send out the null terminator thus len -= 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment