Lying behaviour is important for the welfare of the cow. Therefore, reliable electronic devices may improve the management of the cows, and the devices can be used as a tool in research. However, accelerometer-based devices measure acceleration, and an algorithm is therefore necessary for the calculation of lying behaviour. Thus, validation of such devices is imperative prior to use. The objective of this study was to validate the use of the AfiTagII device for measurements of the lying time and frequency of lying bouts of Danish Holstein (DH) and Danish Jersey (DJ) cows in a loose-house system on two different bedding materials. The validation included correlations and linear regression analyses of data collected by the AfiTagII compared with data collected both by direct observations and recordings from a previously validated device (IceQube). In total, 40 cows were observed directly with primiparous and multiparous DJ and DH cows, equally represented. Furthermore, 21 cows were monitored with both AfiTagII and IceQube devices, and data from both devices were collected simultaneously. The devices were attached to the hind leg of the cow. The estimates of the lying time from the AfiTagII device was highly correlated with the recordings from direct observations (r=0.98), and there was a linear relation between these with an intercept equal to 0 and a slope close to 1. The estimates of the lying time from the AfiTagII device was also highly correlated with the IceQube recordings (r=0.94). However, the intercept deviated from 0. The frequency of lying bouts recorded by the AfiTAgII compared to direct observations showed a positive predictive value of 0.96 for lactating cows on the slatted floor and of 0.85 for the dry cows on the deep bedding. The correlations between frequency of lying bouts recorded with the two devices were high (r=0.94), but the intercept deviated from 0. In conclusion, the AfiTagII has a high accuracy for the measurements of lying behaviour in both DH and DJ cows kept on different bedding materials.