Mac Address

Hello all,
I am sending a load of sensor readings via UDP to a server but one of the problems I am having is that I cannot send my MAC Address I am trying to figure out a way to convert it to a string so that it can be read by PHP

Thanks xD

but one of the problems I am having is that I cannot send my MAC Address

So, what have you tried? The mac address is an array of bytes. It is nearly trivial to convert the elements in the array to ascii. Separating the elements in the string is the only (trivial) challenge.

 packet = {humidity.GetTemperatureC(),humidity.GetHumidity(),epoch,mac[6]};

How is mac defined? Looks to me like you are using the address of the first memory address beyond the location of mac in memory to populate the macaddress array. You can not initialize an array this way.

Sorry but I don't know what I should do, How would I populate the macaddress

How would I populate the macaddress

One element at a time. There are no shortcuts.

I dont know how I would do that, I really would like some help with this and possibly an example of the code required

Since you want to copy an existing array into a new array:

for(int i=0; i<6; i++)
{
  packet.macaddress[i] = mac[i];
}

Why don't you store each mac byte as a variable in your code and then use them as needed? You already know what they are when you write the code.

the reason is that I will be programming over 100 of these devices so by only having to enter the mac address for each device once it will reduce the chance of human error

by adding your code i get the following error on the first line

Adding it where? Show the code.

the only place it will let me place the code is within my void setup or loop

I am sorry I really don't understand how to implement the code, I am very new to programming.

What would I have to amend and what would I have to add to get this to send the mac address?

You have this code that defines, and (improperly) initializes an instance of, a structure.

   struct {
       float temperature;
       float humidity;
       unsigned long etime;   
       byte macaddress[6];
       
       
   }
   
 packet = {humidity.GetTemperatureC(),humidity.GetHumidity(),epoch,mac[6]};

I strongly suggest that you separate the definition of the structure from the initialization of the structure.

// Define a structure
struct contents
{
       float temperature;
       float humidity;
       unsigned long etime;   
       byte macaddress[6];
};

// Create an instance of that structure
struct contents packet;

// Initialize the instance fields
packet.temperature = humidity.GetTemperatureC();
packet.humidity = humidity.GetHumidity();
packet.etime = epoch;
for(int i=0; i<6; i++)
{
  packet.macaddress[i] = mac[i];
}

would I have to change the formatting of the mac address in there?

How are ftemperature, fhumidity, Letime, and Cmacaddress defined? What do you get as the result of the unpack call?

Don't worry, I figured it out in the end. Thanks anyway